Skip to content

Commit ccaecfd

Browse files
committed
bug server: fix lns mismatch in replication
Signed-off-by: adi_holden <adi@dragonflydb.io>
1 parent 3868752 commit ccaecfd

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/server/db_slice.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,6 @@ DbSlice::PrimeItAndExp DbSlice::ExpireIfNeeded(const Context& cntx, PrimeIterato
11671167
}
11681168

11691169
auto& db = db_arr_[cntx.db_index];
1170-
11711170
auto expire_it = db->expire.Find(it->first);
11721171

11731172
if (IsValid(expire_it)) {
@@ -1184,6 +1183,9 @@ DbSlice::PrimeItAndExp DbSlice::ExpireIfNeeded(const Context& cntx, PrimeIterato
11841183
<< ", prime table size: " << db->prime.size() << util::fb2::GetStacktrace();
11851184
}
11861185

1186+
DCHECK(shard_owner()->shard_lock()->Check(IntentLock::Mode::EXCLUSIVE))
1187+
<< util::fb2::GetStacktrace();
1188+
11871189
string scratch;
11881190
string_view key = it->first.GetSlice(&scratch);
11891191

src/server/transaction.cc

+6
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,17 @@ cv_status Transaction::BatonBarrier::Wait(time_point tp) {
150150
Transaction::Guard::Guard(Transaction* tx) : tx(tx) {
151151
DCHECK(tx->cid_->opt_mask() & CO::GLOBAL_TRANS);
152152
tx->Execute([](auto*, auto*) { return OpStatus::OK; }, false);
153+
shard_set->RunBriefInParallel([](EngineShard* shard) {
154+
namespaces->GetDefaultNamespace().GetDbSlice(shard->shard_id()).SetExpireAllowed(false);
155+
});
153156
}
154157

155158
Transaction::Guard::~Guard() {
156159
tx->Conclude();
157160
tx->Refurbish();
161+
shard_set->RunBriefInParallel([](EngineShard* shard) {
162+
namespaces->GetDefaultNamespace().GetDbSlice(shard->shard_id()).SetExpireAllowed(true);
163+
});
158164
}
159165

160166
void Transaction::Init(unsigned num_shards) {

tests/dragonfly/replication_test.py

+1
Original file line numberDiff line numberDiff line change
@@ -2982,6 +2982,7 @@ async def test_bug_in_json_memory_tracking(df_factory: DflyInstanceFactory):
29822982

29832983
seeder = SeederV2(key_target=50_000)
29842984
fill_task = asyncio.create_task(seeder.run(master.client()))
2985+
await asyncio.sleep(0.2)
29852986

29862987
for replica in c_replicas:
29872988
await replica.execute_command(f"REPLICAOF LOCALHOST {master.port}")

0 commit comments

Comments
 (0)