[CC4] CNDB-15558: ULID-based SSTable ID generation can fail with an NPE#2175
Merged
michaelsembwever merged 1 commit intomainfrom Dec 19, 2025
Merged
[CC4] CNDB-15558: ULID-based SSTable ID generation can fail with an NPE#2175michaelsembwever merged 1 commit intomainfrom
michaelsembwever merged 1 commit intomainfrom
Conversation
Checklist before you submit for review
|
Member
Author
|
running CI, and checking if there's a unit test to add here… |
cd8b732 to
fab82ec
Compare
fab82ec to
68d652e
Compare
jkni
requested changes
Dec 18, 2025
jkni
left a comment
There was a problem hiding this comment.
Thanks for the PR! Overall, LGTM and I appreciate the increased test coverage. I left a few minor nits inline. Can you run CNDB CI with a build of this PR?
test/unit/org/apache/cassandra/io/sstable/ULIDBasedSSTableIdGeneratorTest.java
Outdated
Show resolved
Hide resolved
test/unit/org/apache/cassandra/io/sstable/ULIDBasedSSTableIdGeneratorTest.java
Outdated
Show resolved
Hide resolved
test/unit/org/apache/cassandra/io/sstable/ULIDBasedSSTableIdGeneratorTest.java
Outdated
Show resolved
Hide resolved
test/unit/org/apache/cassandra/io/sstable/ULIDBasedSSTableIdGeneratorTest.java
Outdated
Show resolved
Hide resolved
test/unit/org/apache/cassandra/io/sstable/ULIDBasedSSTableIdGeneratorTest.java
Outdated
Show resolved
Hide resolved
test/unit/org/apache/cassandra/io/sstable/ULIDBasedSSTableIdGeneratorTest.java
Outdated
Show resolved
Hide resolved
test/unit/org/apache/cassandra/io/sstable/ULIDBasedSSTableIdGeneratorTest.java
Outdated
Show resolved
Hide resolved
test/unit/org/apache/cassandra/io/sstable/ULIDBasedSSTableIdGeneratorTest.java
Outdated
Show resolved
Hide resolved
ULID-based SSTable ID generation can fail with an NPE when generating a new ID. The root cause is that the underlying ULID generator can generate an empty Optional when the clock is moved backwards to before the previously generated ID or in certain rare overflow conditions when timestamp collides. If it's our first time through the generation loop, we prematurely exit with a null newVal. Top of the error stack: ``` java.lang.NullPointerException at org.apache.cassandra.utils.TimeUUID.approximateFromULID(TimeUUID.java:58) at org.apache.cassandra.io.sstable.ULIDBasedSSTableId.<init>(ULIDBasedSSTableId.java:52) at org.apache.cassandra.io.sstable.ULIDBasedSSTableId$Builder.lambda$generator$0(ULIDBasedSSTableId.java:129) ``` This can cause a flush to fail. Continue looping until newVal gets a value. The loop can spin until the corrected time catches up to the time of the most recently used ULID generation ID. This should be a short duration in a healthy cluster without large time corrections from sync. Tests are added in ULIDBasedSSTableIdGeneratorTest A package-protected constructor is introduced for ULIDBasedSSTableIdGeneratorTest.testGeneratorRetryOnEmptyOptional() Cassandra Applicability: upstream doesn't have ULIDBasedSSTableId (and won't because CASSANDRA-17048).
68d652e to
bd286de
Compare
Member
Author
|
cndb tests: https://github.com/riptano/cndb/pull/16340 |
|
❌ Build ds-cassandra-pr-gate/PR-2175 rejected by Butler3 regressions found Found 3 new test failures
Found 1 known test failures |
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.



https://github.com/riptano/cndb/issues/15558
What is the issue
ULID-based SSTable ID generation can fail with an NPE when generating a new ID. The root cause is that the underlying ULID generator can generate an empty Optional when the clock is moved backwards to before the previously generated ID or in certain rare overflow conditions when timestamp collides. If it's our first time through the generation loop, we prematurely exit with a null newVal.
Top of the error stack:
This can cause a flush to fail.
What does this PR fix and why was it fixed
Continue looping until newVal gets a value. The loop can spin until the corrected time catches up to the time of the most recently used ULID generation ID. This should be a short duration in a healthy cluster without large time corrections from sync.