Skip to content

Commit

Permalink
fix(storage): fix leaving put key after delete keys are dropped cause…
Browse files Browse the repository at this point in the history
… inconsistent (#15232)

Signed-off-by: Little-Wallace <[email protected]>
  • Loading branch information
Little-Wallace authored Feb 23, 2024
1 parent b0a9000 commit e19aaec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/storage/src/hummock/compactor/compactor_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@ where
let mut is_new_user_key = full_key_tracker.observe(iter.key()).is_some();
let mut drop = false;

// CRITICAL WARN: Because of memtable spill, there may be several versions of the same user-key share the same `pure_epoch`. Do not change this code unless necessary.
let epoch = iter_key.epoch_with_gap.pure_epoch();
let value = iter.value();
if is_new_user_key {
Expand Down Expand Up @@ -818,7 +819,9 @@ where
// in our design, frontend avoid to access keys which had be deleted, so we dont
// need to consider the epoch when the compaction_filter match (it
// means that mv had drop)
if (epoch <= task_config.watermark && task_config.gc_delete_keys && value.is_delete())
// Because of memtable spill, there may be a PUT key share the same `pure_epoch` with DELETE key.
// Do not assume that "the epoch of keys behind must be smaller than the current key."
if (epoch < task_config.watermark && task_config.gc_delete_keys && value.is_delete())
|| (epoch < task_config.watermark
&& (watermark_can_see_last_key
|| earliest_range_delete_which_can_see_iter_key <= task_config.watermark))
Expand Down
4 changes: 3 additions & 1 deletion src/storage/src/hummock/compactor/fast_compactor_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,9 @@ impl<F: TableBuilderFactory> CompactTaskExecutor<F> {
self.watermark_can_see_last_key = false;
self.last_key_is_delete = false;
}
if epoch <= self.task_config.watermark

// See note in `compactor_runner.rs`.
if epoch < self.task_config.watermark
&& self.task_config.gc_delete_keys
&& value.is_delete()
{
Expand Down

0 comments on commit e19aaec

Please sign in to comment.