Skip to content

Commit

Permalink
range_tombstone_change_generator: fix an edge case in flush()
Browse files Browse the repository at this point in the history
range_tombstone_change_generator::flush() mishandles the case when two range
tombstones are adjacent and flush(pos, end_of_range=true) is called with pos
equal to the end bound of the lesser-position range tombstone.

In such case, the start change of the greater-position rtc will be accidentally
emitted, and there won't be an end change, which breaks reader assumptions by
ending the stream with an unclosed range tombstone, triggering an assertion.

This is due to a non-strict inequality used in a place where strict inequality
should be used. The modified line was intended to close range tombstones
which end exactly on the flush position, but this is unnecessary because such
range tombstones are handled by the last `if` in the function anyway.
Instead, this line caused range tombstones beginning right after the flush
position to be emitted sometimes.

Fixes #12462

Closes #13906
  • Loading branch information
michoecho authored and tgrabiec committed May 16, 2023
1 parent 24c3cbc commit 9b0679c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mutation/range_tombstone_change_generator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public:

position_in_partition::tri_compare cmp(_schema);
std::optional<range_tombstone> prev;
const bool allow_eq = end_of_range || upper_bound.is_after_all_clustered_rows(_schema);
const bool allow_eq = upper_bound.is_after_all_clustered_rows(_schema);
const auto should_flush = [&] (position_in_partition_view pos) {
const auto res = cmp(pos, upper_bound);
if (allow_eq) {
Expand Down

0 comments on commit 9b0679c

Please sign in to comment.