From 8d5938f24569671e2e3464e32e40a6ca916bafa3 Mon Sep 17 00:00:00 2001 From: Vladislav Oleshko Date: Sun, 30 Nov 2025 12:40:48 +0300 Subject: [PATCH 1/2] fix(core): Remove async delete flag --- src/core/compact_object.h | 8 -------- src/server/db_slice.cc | 10 +++++----- src/server/db_slice.h | 5 +++-- src/server/generic_family.cc | 5 +---- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/core/compact_object.h b/src/core/compact_object.h index 50f1797d9c93..48f0f5beec32 100644 --- a/src/core/compact_object.h +++ b/src/core/compact_object.h @@ -255,14 +255,6 @@ class CompactObj { bool DefragIfNeeded(PageUsage* page_usage); - void SetAsyncDelete() { - mask_bits_.io_pending = 1; // io_pending flag is used for async delete for keys. - } - - bool IsAsyncDelete() const { - return mask_bits_.io_pending; - } - bool HasStashPending() const { return mask_bits_.io_pending; } diff --git a/src/server/db_slice.cc b/src/server/db_slice.cc index 33683152088d..01f217a166e6 100644 --- a/src/server/db_slice.cc +++ b/src/server/db_slice.cc @@ -802,7 +802,7 @@ void DbSlice::ActivateDb(DbIndex db_ind) { CreateDb(db_ind); } -void DbSlice::Del(Context cntx, Iterator it, DbTable* db_table) { +void DbSlice::Del(Context cntx, Iterator it, DbTable* db_table, bool async) { CHECK(IsValid(it)); ExpIterator exp_it; @@ -820,7 +820,7 @@ void DbSlice::Del(Context cntx, Iterator it, DbTable* db_table) { DCHECK(!exp_it.is_done()); } - PerformDeletionAtomic(it, exp_it, table); + PerformDeletionAtomic(it, exp_it, table, async); } void DbSlice::DelMutable(Context cntx, ItAndUpdater it_updater) { @@ -1771,7 +1771,7 @@ unique_ptr DbSlice::StopSampleValues(DbIndex db_ind) { } void DbSlice::PerformDeletionAtomic(const Iterator& del_it, const ExpIterator& exp_it, - DbTable* table) { + DbTable* table, bool async) { FiberAtomicGuard guard; size_t table_before = table->table_memory(); if (!exp_it.is_done()) { @@ -1804,7 +1804,7 @@ void DbSlice::PerformDeletionAtomic(const Iterator& del_it, const ExpIterator& e } AccountObjectMemory(del_it.key(), pv.ObjType(), -value_heap_size, table); // Value - if (del_it->first.IsAsyncDelete() && MayDeleteAsynchronously(pv)) { + if (async && MayDeleteAsynchronously(pv)) { DenseSet* ds = (DenseSet*)pv.RObjPtr(); pv.SetRObjPtr(nullptr); const size_t kClearStepSize = 512; @@ -1815,7 +1815,7 @@ void DbSlice::PerformDeletionAtomic(const Iterator& del_it, const ExpIterator& e } else { CompactObj::DeleteMR(ds); } - } // del_it->first.IsAsyncDelete() + } if (table->slots_stats) { SlotId sid = KeySlot(del_it.key()); diff --git a/src/server/db_slice.h b/src/server/db_slice.h index 6d62c24ea69c..02fb1091b3c8 100644 --- a/src/server/db_slice.h +++ b/src/server/db_slice.h @@ -325,7 +325,7 @@ class DbSlice { // Deletes the iterator. The iterator must be valid. // Context argument is used only for document removal and it just needs // timestamp field. Last argument, db_table, is optional and is used only in FlushSlotsCb. - void Del(Context cntx, Iterator it, DbTable* db_table = nullptr); + void Del(Context cntx, Iterator it, DbTable* db_table = nullptr, bool async = false); // Deletes a key after FindMutable(). Runs post_updater before deletion // to update memory accounting while the key is still valid. @@ -571,7 +571,8 @@ class DbSlice { void RemoveOffloadedEntriesFromTieredStorage(absl::Span indices, const DbTableArray& db_arr) const; - void PerformDeletionAtomic(const Iterator& del_it, const ExpIterator& exp_it, DbTable* table); + void PerformDeletionAtomic(const Iterator& del_it, const ExpIterator& exp_it, DbTable* table, + bool async = false); // Queues invalidation message to the clients that are tracking the change to a key. void QueueInvalidationTrackingMessageAtomic(std::string_view key); diff --git a/src/server/generic_family.cc b/src/server/generic_family.cc index 5387ef988dc9..afd0b6f1cccb 100644 --- a/src/server/generic_family.cc +++ b/src/server/generic_family.cc @@ -1111,10 +1111,7 @@ OpResult GenericFamily::OpDel(const OpArgs& op_args, const ShardArgs& if (!IsValid(it)) continue; - if (async) - it->first.SetAsyncDelete(); - - db_slice.Del(op_args.db_cntx, it); + db_slice.Del(op_args.db_cntx, it, aync); ++res; } From 4472335ccc401eaeaf0e9f858d5c4d80287c5912 Mon Sep 17 00:00:00 2001 From: Vladislav Oleshko Date: Sun, 30 Nov 2025 12:42:41 +0300 Subject: [PATCH 2/2] update comment Signed-off-by: Vladislav Oleshko --- src/core/compact_object.h | 6 +++--- src/server/db_slice.h | 1 + src/server/generic_family.cc | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/compact_object.h b/src/core/compact_object.h index 48f0f5beec32..77a402f761b1 100644 --- a/src/core/compact_object.h +++ b/src/core/compact_object.h @@ -534,8 +534,8 @@ class CompactObj { union { uint8_t mask_ = 0; struct { - uint8_t ref : 1; // Mark objects that have expiry timestamp assigned. - uint8_t expire : 1; + uint8_t ref : 1; // Mark objects that don't own their allocation. + uint8_t expire : 1; // Mark objects that have expiry timestamp assigned. uint8_t mc_flag : 1; // Marks keys that have memcache flags assigned. // See the EncodingEnum for the meaning of these bits. @@ -543,7 +543,7 @@ class CompactObj { // IO_PENDING is set when the tiered storage has issued an i/o request to save the value. // It is cleared when the io request finishes or is cancelled. - uint8_t io_pending : 1; // also serves as async-delete for keys. + uint8_t io_pending : 1; uint8_t sticky : 1; // TOUCHED used to determin which items are hot/cold. diff --git a/src/server/db_slice.h b/src/server/db_slice.h index 02fb1091b3c8..4785890e9b7a 100644 --- a/src/server/db_slice.h +++ b/src/server/db_slice.h @@ -325,6 +325,7 @@ class DbSlice { // Deletes the iterator. The iterator must be valid. // Context argument is used only for document removal and it just needs // timestamp field. Last argument, db_table, is optional and is used only in FlushSlotsCb. + // If async is set, AsyncDeleter will enqueue deletion of the object void Del(Context cntx, Iterator it, DbTable* db_table = nullptr, bool async = false); // Deletes a key after FindMutable(). Runs post_updater before deletion diff --git a/src/server/generic_family.cc b/src/server/generic_family.cc index afd0b6f1cccb..9e42d8fdddc9 100644 --- a/src/server/generic_family.cc +++ b/src/server/generic_family.cc @@ -1111,7 +1111,7 @@ OpResult GenericFamily::OpDel(const OpArgs& op_args, const ShardArgs& if (!IsValid(it)) continue; - db_slice.Del(op_args.db_cntx, it, aync); + db_slice.Del(op_args.db_cntx, it, nullptr, async); ++res; }