Skip to content

CNDB-17010: Fix CC4→CC5 memtable configuration loss during upgrade#2261

Merged
djatnieks merged 11 commits intomain-5.0from
CNDB-17010
Mar 20, 2026
Merged

CNDB-17010: Fix CC4→CC5 memtable configuration loss during upgrade#2261
djatnieks merged 11 commits intomain-5.0from
CNDB-17010

Conversation

@djatnieks
Copy link
Copy Markdown
Member

What is the issue

CNDB-17010

What does this PR fix and why was it fixed

CC4 stored the memtable column in system_schema.tables as frozen<map<text, text>>, while CC5 uses text. During upgrades, binary-serialized map data is misinterpreted as UTF-8 text, causing memtable configurations to fall back to defaults.

Changes:

  • Add MemtableParams.getWithCC4Fallback() to detect and parse binary map data using null-byte heuristic
  • Add mapCC4ClassNameToCC5Key() to map CC4 class names (TrieMemtable, SkipListMemtable) to CC5 config keys
  • Update SchemaKeyspace.createTableParamsFromRow() to use new compatibility method

CC4 stored the memtable column in system_schema.tables as
frozen<map<text, text>>, while CC5 uses text. During upgrades,
binary-serialized map data is misinterpreted as UTF-8 text,
causing memtable configurations to fall back to defaults.

Changes:
- Add MemtableParams.getWithCC4Fallback() to detect and parse
  binary map data using null-byte heuristic
- Add mapCC4ClassNameToCC5Key() to map CC4 class names
  (TrieMemtable, SkipListMemtable) to CC5 config keys
- Update SchemaKeyspace.createTableParamsFromRow() to use
  new compatibility method
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 7, 2026

Checklist before you submit for review

  • This PR adheres to the Definition of Done
  • Make sure there is a PR in the CNDB project updating the Converged Cassandra version
  • Use NoSpamLogger for log lines that may appear frequently in the logs
  • Verify test results on Butler
  • Test coverage for new/modified code is > 80%
  • Proper code formatting
  • Proper title for each commit staring with the project-issue number, like CNDB-1234
  • Each commit has a meaningful description
  • Each commit is not very long and contains related changes
  • Renames, moves and reformatting are in distinct commits
  • All new files should contain the DataStax copyright header instead of the Apache License one

@djatnieks djatnieks requested a review from driftx March 9, 2026 17:03
@djatnieks djatnieks marked this pull request as ready for review March 9, 2026 17:12
@djatnieks
Copy link
Copy Markdown
Member Author

I think that tables created with CC5 and the text memtable column could cause problems if that node is then downgraded back to CC4. I don't think the SCM setting handles this and not sure if it should.

@driftx
Copy link
Copy Markdown

driftx commented Mar 10, 2026

I think we could do this with SCM at the schema level rather than at read time, such that we maintain the CC4 map approach when SCM is < 5 and then upgrade it away from the map when SCM is changed. This would be similar (but more involved) to the way we delay other schema changes with SCM now, and allows us to avoid the byte sniffing to detect the correct format. WDYT?

@djatnieks
Copy link
Copy Markdown
Member Author

I think we could do this with SCM at the schema level rather than at read time, such that we maintain the CC4 map approach when SCM is < 5 and then upgrade it away from the map when SCM is changed. This would be similar (but more involved) to the way we delay other schema changes with SCM now, and allows us to avoid the byte sniffing to detect the correct format. WDYT?

Yes, that would be much better - and resolve the downgrade concern. I overlooked existing use of SCM to delay schema changes initially, but see them there now and give that at try.

CC5 changed the memtable column in system_schema.tables/views from
frozen<map<text, text>> (CC4) to text (CC5). This prevents safe
downgrades from CC5 to CC4 when storage_compatibility_mode is set.

This commit adds bidirectional compatibility:
- Reading: Previous commit (abdbcf1) handles CC4→CC5 upgrades
- Writing: This commit handles CC5→CC4 downgrades
Comment thread src/java/org/apache/cassandra/schema/MemtableParams.java
Comment thread src/java/org/apache/cassandra/schema/MemtableParams.java Outdated
@djatnieks djatnieks requested a review from driftx March 12, 2026 01:10
Comment thread src/java/org/apache/cassandra/schema/MemtableParams.java Outdated
Comment thread src/java/org/apache/cassandra/schema/SchemaKeyspace.java Outdated
Comment thread src/java/org/apache/cassandra/schema/MemtableParams.java Outdated
Comment thread src/java/org/apache/cassandra/schema/MemtableParams.java
Replace hardcoded switch statement with dynamic lookup from
CONFIGURATION_DEFINITIONS. Get actual class name from
definition.class_name instead of synthesizing it.
@djatnieks djatnieks requested a review from driftx March 13, 2026 19:44
Comment thread src/java/org/apache/cassandra/schema/SchemaKeyspace.java Outdated
Copy link
Copy Markdown

@driftx driftx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a few more issues around backward-compatibility. We should perhaps add a test that covers those too.

Comment thread src/java/org/apache/cassandra/schema/SchemaKeyspace.java Outdated
Comment thread src/java/org/apache/cassandra/schema/SchemaKeyspace.java Outdated
Comment thread src/java/org/apache/cassandra/schema/SchemaKeyspace.java Outdated
…and viewTablesMetadata that use SCM to determine the correct table/view metadata to use.
@djatnieks djatnieks requested a review from driftx March 19, 2026 00:39
Copy link
Copy Markdown

@driftx driftx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just one last thing I missed before.

Comment thread src/java/org/apache/cassandra/schema/MemtableParams.java Outdated
Tests now run in all compatibility modes (NONE, CC_4, CASSANDRA_4)
and validate correct schema table metadata selection.
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@cassci-bot
Copy link
Copy Markdown

❌ Build ds-cassandra-pr-gate/PR-2261 rejected by Butler


3 regressions found
See build details here


Found 3 new test failures

Test Explanation Runs Upstream
o.a.c.index.sai.cql.VectorCompaction100dTest.testOneToManyCompactionTooManyHoles[eb false] () NEW 🔴 0 / 26
o.a.c.index.sai.cql.VectorSiftSmallTest.testCompaction[db false] () NEW 🔴 0 / 26
o.a.c.index.sai.disk.v1.SegmentFlushTest.testFlushBetweenRowIds[aa] () NEW 🔴 0 / 26

Found 4 known test failures

@djatnieks djatnieks requested a review from driftx March 19, 2026 23:33
@djatnieks djatnieks merged commit 59b9094 into main-5.0 Mar 20, 2026
1 of 4 checks passed
@djatnieks djatnieks deleted the CNDB-17010 branch March 20, 2026 17:26
michaelsembwever pushed a commit that referenced this pull request Mar 25, 2026
…2261)

### What is the issue
CNDB-17010

### What does this PR fix and why was it fixed
CC4 stored the memtable column in system_schema.tables as
frozen<map<text, text>>, while CC5 uses text. During upgrades,
binary-serialized map data is misinterpreted as UTF-8 text, causing
memtable configurations to fall back to defaults.
michaelsembwever pushed a commit that referenced this pull request Mar 27, 2026
…2261)

### What is the issue
CNDB-17010

### What does this PR fix and why was it fixed
CC4 stored the memtable column in system_schema.tables as
frozen<map<text, text>>, while CC5 uses text. During upgrades,
binary-serialized map data is misinterpreted as UTF-8 text, causing
memtable configurations to fall back to defaults.
michaelsembwever pushed a commit that referenced this pull request Apr 14, 2026
…2261)

### What is the issue
CNDB-17010

### What does this PR fix and why was it fixed
CC4 stored the memtable column in system_schema.tables as
frozen<map<text, text>>, while CC5 uses text. During upgrades,
binary-serialized map data is misinterpreted as UTF-8 text, causing
memtable configurations to fall back to defaults.
michaelsembwever pushed a commit that referenced this pull request Apr 15, 2026
…2261)

### What is the issue
CNDB-17010

### What does this PR fix and why was it fixed
CC4 stored the memtable column in system_schema.tables as
frozen<map<text, text>>, while CC5 uses text. During upgrades,
binary-serialized map data is misinterpreted as UTF-8 text, causing
memtable configurations to fall back to defaults.
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.

3 participants