CASSANALYTICS-202: Opening one keyspace instance rebuilds every keysp… - #249
Merged
Merged
Conversation
sarankk
approved these changes
Sep 28, 2026
sarankk
left a comment
Contributor
There was a problem hiding this comment.
+1 Thanks Mansi for this find and fix!
…ace instance in the Cassandra 6.0 bridge AbstractSchemaBuilder created a missing keyspace instance by calling SchemaUpdater.openKeyspaceInstances(), which diffs the current cluster metadata against DistributedSchema.empty(). Every keyspace in the process therefore looks newly created and all of them are rebuilt, so each keyspace that already has an instance constructs its KeyspaceMetrics again, and every metric it re-registers makes Dropwizard's MetricRegistry.register throw IllegalArgumentException. Filling in those stack traces is the real cost, and it scales with the number of keyspaces the process has seen. This does not affect production, where a bulk job uses a single keyspace and builds its schema once. It is visible in tests: DataTypeTests opens a fresh keyspace per generated case, so the 6.0 core test job slowed down through the class until the CI step exceeded its deadline part way through. Two thread dumps taken fifteen seconds apart were both in Throwable.fillInStackTrace under MetricRegistry.register, and jstat ruled out memory pressure with zero full collections and seven seconds of GC across twelve minutes. openKeyspaceInstances() is replaced by openKeyspaceInstance(String), which diffs against the current keyspaces minus the one being opened, leaving exactly one keyspace in Keyspaces.diff().created so a single instance is built and no metric is registered twice. That also keeps the keyspace out of diff().altered, which is the property removeTables relies on to avoid Keyspace.dropCf initializing CompactionManager in client mode, so the CDC caller passes keyspaceMetadata.name and the blunt method is removed altogether. DataTypeTests on 6.0 goes from not completing to about ten minutes.
mansikhara
force-pushed
the
CASSANALYTICS-202
branch
from
September 29, 2026 15:52
7dc6780 to
2d04dd1
Compare
yifan-c
approved these changes
Sep 29, 2026
sarankk
pushed a commit
that referenced
this pull request
Sep 29, 2026
…ace instance in the Cassandra 6.0 bridge (#249) Patch by Mansi Khara; Reviewed by Yifan Cai, Bernardo Botella, Saranya Krishnakumar for CASSANALYTICS-202
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…ace instance in the Cassandra 6.0 bridge
AbstractSchemaBuilder created a missing keyspace instance by calling SchemaUpdater.openKeyspaceInstances(), which diffs the current cluster metadata against DistributedSchema.empty(). Every keyspace in the process therefore looks newly created and all of them are rebuilt, so each keyspace that already has an instance constructs its KeyspaceMetrics again, and every metric it re-registers makes Dropwizard's MetricRegistry.register throw IllegalArgumentException. Filling in those stack traces is the real cost, and it scales with the number of keyspaces the process has seen.
This does not affect production, where a bulk job uses a single keyspace and builds its schema once. It is visible in tests: DataTypeTests opens a fresh keyspace per generated case, so the 6.0 core test job slowed down through the class until the CI step exceeded its deadline part way through. Two thread dumps taken fifteen seconds apart were both in Throwable.fillInStackTrace under MetricRegistry.register, and jstat ruled out memory pressure with zero full collections and seven seconds of GC across twelve minutes.
openKeyspaceInstances() is replaced by openKeyspaceInstance(String), which diffs against the current keyspaces minus the one being opened, leaving exactly one keyspace in Keyspaces.diff().created so a single instance is built and no metric is registered twice. That also keeps the keyspace out of diff().altered, which is the property removeTables relies on to avoid Keyspace.dropCf initializing CompactionManager in client mode, so the CDC caller passes keyspaceMetadata.name and the blunt method is removed altogether.
DataTypeTests on 6.0 goes from not completing to about ten minutes.