diff --git a/src/core/compact_object.h b/src/core/compact_object.h index 50f1797d9c93..77a402f761b1 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; } @@ -542,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. @@ -551,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.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..4785890e9b7a 100644 --- a/src/server/db_slice.h +++ b/src/server/db_slice.h @@ -325,7 +325,8 @@ 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); + // 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 // to update memory accounting while the key is still valid. @@ -571,7 +572,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..9e42d8fdddc9 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, nullptr, async); ++res; }