Skip to content
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

fix(storage): fix leaving put key after delete keys are dropped cause inconsistent #15232

Merged
merged 2 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading