Skip to content

CASSANDRA-21156 Avoid initializing system keyspaces during legacy threshold conversion - #5156

Open
cheeeee wants to merge 1 commit into
apache:trunkfrom
cheeeee:CASSANDRA-21156-trunk
Open

CASSANDRA-21156 Avoid initializing system keyspaces during legacy threshold conversion#5156
cheeeee wants to merge 1 commit into
apache:trunkfrom
cheeeee:CASSANDRA-21156-trunk

Conversation

@cheeeee

@cheeeee cheeeee commented Sep 11, 2026

Copy link
Copy Markdown

CASSANDRA-21156: setting the legacy table_count_warn_threshold (or keyspace_count_warn_threshold) makes
startup fail with ExceptionInInitializerError. The YAML converter for these keys calls
SchemaConstants.getLocalAndReplicatedSystemTableNames(), which initializes SystemKeyspace and the other
system keyspace classes; their static initializers read DatabaseDescriptor, which is still being loaded,
and throw NullPointerException.

Changes:

  • The per-keyspace table-name sets are declared in SchemaConstants and built only from the String
    constants of SystemKeyspace, TraceKeyspace, AuthKeyspace, SystemDistributedKeyspace and AccordKeyspace.
    Referencing a compile-time constant does not trigger class initialization (JLS 12.4.1), so the
    converter no longer initializes any keyspace class. The TABLE_NAMES fields of those classes now alias
    the SchemaConstants sets, so there is a single definition.
  • Converters: the two thresholds share one clamp. Values <= 0 pass through unchanged in both directions
    (guardrail disabled). A legacy value that is not larger than the number of system tables/keyspaces now
    converts to 0 with a warning, i.e. warn on any user creation; it used to convert to a zero or negative
    number. This is a semantics change for such (unusually small) legacy values.

Testing:

  • TableCountThresholdToGuardrailConverterTest (fresh JVM, no configuration loaded): converts both
    thresholds and asserts DatabaseDescriptor.getRawConfig() is still null afterwards, plus the boundary
    values of the clamp. Without the change it fails with the ExceptionInInitializerError from the ticket
    (SystemKeyspace. via SchemaConstants via Converters).
  • SystemTableNamesConsistencyTest: each SchemaConstants set equals the table names of the corresponding
    keyspace metadata, so the hoisted constants cannot drift from the real schema.
  • AccordJournalDaemonYamlInitializationTest, AccordJournalToolYamlInitializationTest (each in a fresh
    JVM): the journal_sai index on system_accord.journal is still configured after YAML initialization in
    daemon and in tool mode.

CASSANDRA-21156

@cheeeee
cheeeee force-pushed the CASSANDRA-21156-trunk branch from 3fb8629 to cdf3435 Compare September 11, 2026 22:51
@cheeeee cheeeee changed the title CASSANDRA-21156: Prevent cyclic static initialization during table count threshold conversion CASSANDRA-21156 Avoid initializing system keyspaces during legacy threshold conversion Sep 11, 2026
Resolve system table names from configuration-independent constants. Keep
Accord journal metadata sensitive to the loaded configuration in both tool
and daemon initialization, without a daemon-only index guard. Exercise
fresh-JVM initialization orderings and converter boundaries.

CASSANDRA-21156

Generated-by: Claude (Anthropic)
@cheeeee
cheeeee force-pushed the CASSANDRA-21156-trunk branch from cdf3435 to 70f5d0c Compare September 12, 2026 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant