Skip to content

Commit c059644

Browse files
author
Nitsan Wakart
committed
Validate tombstone close/boundary only after open
1 parent 291ae9c commit c059644

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/java/org/apache/cassandra/db/compaction/StatefulCursor.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class StatefulCursor extends SSTableCursorReader
5252
private boolean resetAfterDone = false;
5353
private long bytesReadPositionSnapshot = 0;
5454

55+
private boolean isOpenRangeTombstonePresent = false;
56+
5557
public StatefulCursor(SSTableReader reader)
5658
{
5759
super(reader);
@@ -176,8 +178,17 @@ public void readRowHeader()
176178
public void readTombstoneMarker()
177179
{
178180
super.readTombstoneMarker(unfiltered);
181+
179182
if (corruptedTombstoneValidationEnabled)
180183
validateInvalidTombstoneDeletion();
184+
185+
boolean isStartBound = unfiltered.isStartBound();
186+
if (isOpenRangeTombstonePresent && isStartBound)
187+
corruptSSTable("Encountered an open range tombstone marker before the prev was closed: " + unfiltered);
188+
if (!isOpenRangeTombstonePresent && !isStartBound)
189+
corruptSSTable("Encountered an close/boundary range tombstone marker before an open one: " + unfiltered);
190+
isOpenRangeTombstonePresent = isStartBound || unfiltered.isBoundary();
191+
// TODO: can also add verification of open/close timestamp match
181192
}
182193

183194
public void readStaticRowHeader()

0 commit comments

Comments
 (0)