Skip to content

Commit 7b50a5d

Browse files
committed
properly clean up thread local
1 parent c04f96d commit 7b50a5d

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

src/server/common.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ ThreadLocalMutex::ThreadLocalMutex() {
430430
}
431431

432432
ThreadLocalMutex::~ThreadLocalMutex() {
433-
// DCHECK_EQ(EngineShard::tlocal(), shard_);
433+
DCHECK_EQ(EngineShard::tlocal(), shard_);
434434
}
435435

436436
void ThreadLocalMutex::lock() {

src/server/db_slice.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,6 @@ unsigned PrimeEvictionPolicy::Evict(const PrimeTable::HotspotBuckets& eb, PrimeT
206206
if (auto journal = db_slice_->shard_owner()->journal(); journal) {
207207
RecordExpiry(cntx_.db_index, key);
208208
}
209-
// Safe we already acquired util::fb2::LockGuard lk(db_slice_->GetSerializationMutex());
210-
// on the flows that call this function
211209
db_slice_->PerformDeletion(DbSlice::Iterator(last_slot_it, StringOrView::FromView(key)), table);
212210

213211
++evicted_;
@@ -1131,6 +1129,11 @@ DbSlice::PrimeItAndExp DbSlice::ExpireIfNeeded(const Context& cntx, PrimeIterato
11311129
<< ", prime table size: " << db->prime.size() << util::fb2::GetStacktrace();
11321130
}
11331131

1132+
// Replicate expiry
1133+
if (auto journal = owner_->journal(); journal) {
1134+
RecordExpiry(cntx.db_index, key);
1135+
}
1136+
11341137
if (expired_keys_events_recording_)
11351138
db->expired_keys_events_.emplace_back(key);
11361139

@@ -1142,10 +1145,6 @@ DbSlice::PrimeItAndExp DbSlice::ExpireIfNeeded(const Context& cntx, PrimeIterato
11421145
const_cast<DbSlice*>(this)->PerformDeletion(Iterator(it, StringOrView::FromView(key)),
11431146
ExpIterator(expire_it, StringOrView::FromView(key)),
11441147
db.get());
1145-
// Replicate expiry
1146-
if (auto journal = owner_->journal(); journal) {
1147-
RecordExpiry(cntx.db_index, key);
1148-
}
11491148

11501149
++events_.expired_keys;
11511150

src/server/dflycmd.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,12 @@ OpStatus DflyCmd::StartFullSyncInThread(FlowInfo* flow, Context* cntx, EngineSha
589589
void DflyCmd::StopFullSyncInThread(FlowInfo* flow, Context* cntx, EngineShard* shard) {
590590
DCHECK(shard);
591591

592+
absl::Cleanup clean([&]() {
593+
// Reset cleanup and saver
594+
flow->cleanup = []() {};
595+
flow->saver.reset();
596+
});
597+
592598
error_code ec = flow->saver->StopFullSyncInShard(shard);
593599
if (ec) {
594600
cntx->ReportError(ec);
@@ -600,10 +606,6 @@ void DflyCmd::StopFullSyncInThread(FlowInfo* flow, Context* cntx, EngineShard* s
600606
cntx->ReportError(ec);
601607
return;
602608
}
603-
604-
// Reset cleanup and saver
605-
flow->cleanup = []() {};
606-
flow->saver.reset();
607609
}
608610

609611
void DflyCmd::StartStableSyncInThread(FlowInfo* flow, Context* cntx, EngineShard* shard) {

0 commit comments

Comments
 (0)