Skip to content

Commit f6be2f3

Browse files
authored
fix(core): Remove async delete flag (#6139)
1 parent 390830f commit f6be2f3

File tree

4 files changed

+13
-22
lines changed

4 files changed

+13
-22
lines changed

src/core/compact_object.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,6 @@ class CompactObj {
255255

256256
bool DefragIfNeeded(PageUsage* page_usage);
257257

258-
void SetAsyncDelete() {
259-
mask_bits_.io_pending = 1; // io_pending flag is used for async delete for keys.
260-
}
261-
262-
bool IsAsyncDelete() const {
263-
return mask_bits_.io_pending;
264-
}
265-
266258
bool HasStashPending() const {
267259
return mask_bits_.io_pending;
268260
}
@@ -547,16 +539,16 @@ class CompactObj {
547539
union {
548540
uint8_t mask_ = 0;
549541
struct {
550-
uint8_t ref : 1; // Mark objects that have expiry timestamp assigned.
551-
uint8_t expire : 1;
542+
uint8_t ref : 1; // Mark objects that don't own their allocation.
543+
uint8_t expire : 1; // Mark objects that have expiry timestamp assigned.
552544
uint8_t mc_flag : 1; // Marks keys that have memcache flags assigned.
553545

554546
// See the EncodingEnum for the meaning of these bits.
555547
uint8_t encoding : 2;
556548

557549
// IO_PENDING is set when the tiered storage has issued an i/o request to save the value.
558550
// It is cleared when the io request finishes or is cancelled.
559-
uint8_t io_pending : 1; // also serves as async-delete for keys.
551+
uint8_t io_pending : 1;
560552
uint8_t sticky : 1;
561553

562554
// TOUCHED used to determin which items are hot/cold.

src/server/db_slice.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ void DbSlice::ActivateDb(DbIndex db_ind) {
802802
CreateDb(db_ind);
803803
}
804804

805-
void DbSlice::Del(Context cntx, Iterator it, DbTable* db_table) {
805+
void DbSlice::Del(Context cntx, Iterator it, DbTable* db_table, bool async) {
806806
CHECK(IsValid(it));
807807

808808
ExpIterator exp_it;
@@ -820,7 +820,7 @@ void DbSlice::Del(Context cntx, Iterator it, DbTable* db_table) {
820820
DCHECK(!exp_it.is_done());
821821
}
822822

823-
PerformDeletionAtomic(it, exp_it, table);
823+
PerformDeletionAtomic(it, exp_it, table, async);
824824
}
825825

826826
void DbSlice::DelMutable(Context cntx, ItAndUpdater it_updater) {
@@ -1771,7 +1771,7 @@ unique_ptr<base::Histogram> DbSlice::StopSampleValues(DbIndex db_ind) {
17711771
}
17721772

17731773
void DbSlice::PerformDeletionAtomic(const Iterator& del_it, const ExpIterator& exp_it,
1774-
DbTable* table) {
1774+
DbTable* table, bool async) {
17751775
FiberAtomicGuard guard;
17761776
size_t table_before = table->table_memory();
17771777
if (!exp_it.is_done()) {
@@ -1804,7 +1804,7 @@ void DbSlice::PerformDeletionAtomic(const Iterator& del_it, const ExpIterator& e
18041804
}
18051805
AccountObjectMemory(del_it.key(), pv.ObjType(), -value_heap_size, table); // Value
18061806

1807-
if (del_it->first.IsAsyncDelete() && MayDeleteAsynchronously(pv)) {
1807+
if (async && MayDeleteAsynchronously(pv)) {
18081808
DenseSet* ds = (DenseSet*)pv.RObjPtr();
18091809
pv.SetRObjPtr(nullptr);
18101810
const size_t kClearStepSize = 512;
@@ -1815,7 +1815,7 @@ void DbSlice::PerformDeletionAtomic(const Iterator& del_it, const ExpIterator& e
18151815
} else {
18161816
CompactObj::DeleteMR<DenseSet>(ds);
18171817
}
1818-
} // del_it->first.IsAsyncDelete()
1818+
}
18191819

18201820
if (table->slots_stats) {
18211821
SlotId sid = KeySlot(del_it.key());

src/server/db_slice.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ class DbSlice {
325325
// Deletes the iterator. The iterator must be valid.
326326
// Context argument is used only for document removal and it just needs
327327
// timestamp field. Last argument, db_table, is optional and is used only in FlushSlotsCb.
328-
void Del(Context cntx, Iterator it, DbTable* db_table = nullptr);
328+
// If async is set, AsyncDeleter will enqueue deletion of the object
329+
void Del(Context cntx, Iterator it, DbTable* db_table = nullptr, bool async = false);
329330

330331
// Deletes a key after FindMutable(). Runs post_updater before deletion
331332
// to update memory accounting while the key is still valid.
@@ -571,7 +572,8 @@ class DbSlice {
571572
void RemoveOffloadedEntriesFromTieredStorage(absl::Span<const DbIndex> indices,
572573
const DbTableArray& db_arr) const;
573574

574-
void PerformDeletionAtomic(const Iterator& del_it, const ExpIterator& exp_it, DbTable* table);
575+
void PerformDeletionAtomic(const Iterator& del_it, const ExpIterator& exp_it, DbTable* table,
576+
bool async = false);
575577

576578
// Queues invalidation message to the clients that are tracking the change to a key.
577579
void QueueInvalidationTrackingMessageAtomic(std::string_view key);

src/server/generic_family.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,10 +1111,7 @@ OpResult<uint32_t> GenericFamily::OpDel(const OpArgs& op_args, const ShardArgs&
11111111
if (!IsValid(it))
11121112
continue;
11131113

1114-
if (async)
1115-
it->first.SetAsyncDelete();
1116-
1117-
db_slice.Del(op_args.db_cntx, it);
1114+
db_slice.Del(op_args.db_cntx, it, nullptr, async);
11181115
++res;
11191116
}
11201117

0 commit comments

Comments
 (0)