-
Notifications
You must be signed in to change notification settings - Fork 3.7k
CASSANDRA-20570: Fixed Leveled Compaction doesn't validate maxBytesForLevel when the table is altered/created #4228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nikhilkumawat03
wants to merge
1
commit into
apache:trunk
Choose a base branch
from
nikhilkumawat03:cassandra-20570
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+50
−3
Conversation
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
Maxwell-Guo
reviewed
Jul 7, 2025
src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
Outdated
Show resolved
Hide resolved
dcapwell
reviewed
Jul 7, 2025
src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
Outdated
Show resolved
Hide resolved
src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
Outdated
Show resolved
Hide resolved
test/unit/org/apache/cassandra/db/compaction/LeveledCompactionStrategyTest.java
Outdated
Show resolved
Hide resolved
test/unit/org/apache/cassandra/db/compaction/LeveledCompactionStrategyTest.java
Outdated
Show resolved
Hide resolved
test/unit/org/apache/cassandra/db/compaction/LeveledCompactionStrategyTest.java
Outdated
Show resolved
Hide resolved
test/unit/org/apache/cassandra/db/compaction/LeveledCompactionStrategyTest.java
Outdated
Show resolved
Hide resolved
test/unit/org/apache/cassandra/db/compaction/LeveledCompactionStrategyTest.java
Outdated
Show resolved
Hide resolved
Maxwell-Guo
reviewed
Jul 8, 2025
src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
Show resolved
Hide resolved
Maxwell-Guo
reviewed
Jul 8, 2025
test/unit/org/apache/cassandra/db/compaction/LeveledCompactionStrategyTest.java
Show resolved
Hide resolved
test/unit/org/apache/cassandra/db/compaction/LeveledCompactionStrategyTest.java
Outdated
Show resolved
Hide resolved
dcapwell
reviewed
Jul 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mostly small changes but direction i am +1 on. Will give my official +1 once open comments are addressed
Maxwell-Guo
reviewed
Jul 9, 2025
Maxwell-Guo
approved these changes
Jul 9, 2025
…rLevel when the table is altered/created Addressed round 1 review comments Addressed round 1 review comments Test case paradigm are improved Unused Library removed
c990956
to
880c653
Compare
df3eb40
to
54e39a9
Compare
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.
Issue Description:
Fuzz testing revealed a RuntimeException in LeveledManifest.maxBytesForLevel during repair operations when compaction parameters cause the calculated maximum bytes for a level to exceed Long.MAX_VALUE (9,223,372,036,854,775,807). The error occurs with inputs like fanout_size=90, sstable_size_in_mb=1088, and level=8, resulting in Math.pow(90, 8) * 1141899264 ≈ 4.9155 × 10²⁴, which exceeds Long.MAX_VALUE. The issue arises because LeveledCompactionStrategy does not validate these parameters during table creation, allowing invalid configurations to persist until repair.
The original error (from LeveledManifest.java):
java.lang.RuntimeException: At most 9223372036854775807 bytes may be in a compaction level; your maxSSTableSize must be absurdly high to compute 4.915501902751334E24
This PR adds proactive validation in LeveledCompactionStrategy.validateOptions to ensure fanout_size and sstable_size_in_mb do not cause an overflow, throwing a ConfigurationException during CREATE TABLE or ALTER TABLE instead of failing later during repair.
Example which created issue during fuzz testing (CASSANDRA-20570)
Patch by: Nikhil Kumawat;
Reviewed by: TBD
JIRA: CASSANDRA-20570