diff --git a/HISTORY.md b/HISTORY.md index 6c640422d..12548a7d8 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -14,6 +14,7 @@ * Add rollback_deletion_type_callback to TransactionDBOptions so that write-prepared transactions know whether to issue a Delete or SingleDelete to cancel a previous key written during prior prepare phase. The PR aims to prevent mixing SingleDeletes and Deletes for the same key that can lead to undefined behaviors for write-prepared transactions. * EXPERIMENTAL: Add new API AbortIO in file_system to abort the read requests submitted asynchronously. * CompactionFilter::Decision has a new value: kRemoveWithSingleDelete. If CompactionFilter returns this decision, then CompactionIterator will use `SingleDelete` to mark a key as removed. +* Renamed CompactionFilter::Decision::kRemoveWithSingleDelete to kPurge since the latter sounds more general and hides the implementation details of how compaction iterator handles keys. ### Bug Fixes * RocksDB calls FileSystem::Poll API during FilePrefetchBuffer destruction which impacts performance as it waits for read requets completion which is not needed anymore. Calling FileSystem::AbortIO to abort those requests instead fixes that performance issue. diff --git a/db/compaction/compaction_iterator.cc b/db/compaction/compaction_iterator.cc index be7b94997..574c02ae6 100644 --- a/db/compaction/compaction_iterator.cc +++ b/db/compaction/compaction_iterator.cc @@ -307,7 +307,7 @@ bool CompactionIterator::InvokeFilterIfNeeded(bool* need_skip, // no value associated with delete value_.clear(); iter_stats_.num_record_drop_user++; - } else if (filter == CompactionFilter::Decision::kRemoveWithSingleDelete) { + } else if (filter == CompactionFilter::Decision::kPurge) { // convert the current key to a single delete; key_ is pointing into // current_key_ at this point, so updating current_key_ updates key() ikey_.type = kTypeSingleDeletion; diff --git a/db/db_compaction_filter_test.cc b/db/db_compaction_filter_test.cc index 5a3f27d12..195615191 100644 --- a/db/db_compaction_filter_test.cc +++ b/db/db_compaction_filter_test.cc @@ -998,7 +998,7 @@ TEST_F(DBTestCompactionFilter, DropKeyWithSingleDelete) { std::string* /*new_value*/, std::string* /*skip_until*/) const override { if (key.starts_with("b")) { - return Decision::kRemoveWithSingleDelete; + return Decision::kPurge; } return Decision::kRemove; } diff --git a/db_stress_tool/db_stress_compaction_filter.h b/db_stress_tool/db_stress_compaction_filter.h index c967622db..d79ba4780 100644 --- a/db_stress_tool/db_stress_compaction_filter.h +++ b/db_stress_tool/db_stress_compaction_filter.h @@ -51,8 +51,7 @@ class DbStressCompactionFilter : public CompactionFilter { key_mutex->Unlock(); if (!key_exists) { - return allow_overwrite ? Decision::kRemove - : Decision::kRemoveWithSingleDelete; + return allow_overwrite ? Decision::kRemove : Decision::kPurge; } return Decision::kKeep; } diff --git a/include/rocksdb/compaction_filter.h b/include/rocksdb/compaction_filter.h index 29f7fae8f..57668a24e 100644 --- a/include/rocksdb/compaction_filter.h +++ b/include/rocksdb/compaction_filter.h @@ -39,11 +39,11 @@ class CompactionFilter : public Customizable { enum class Decision { kKeep, kRemove, - kRemoveWithSingleDelete, kChangeValue, kRemoveAndSkipUntil, kChangeBlobIndex, // used internally by BlobDB. kIOError, // used internally by BlobDB. + kPurge, // used for keys that can only be SingleDelete'ed kUndetermined, };