From 9a39929ce4652428ce7de21534e6d4ec8830fce7 Mon Sep 17 00:00:00 2001 From: adi_holden Date: Sun, 26 Feb 2023 12:39:22 +0200 Subject: [PATCH] feat(db slice): add fiber atomic gaurd Signed-off-by: adi_holden --- .github/workflows/regression-tests.yml | 2 +- src/server/db_slice.cc | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/regression-tests.yml b/.github/workflows/regression-tests.yml index e898c22d2c13..c3c7357a82ca 100644 --- a/.github/workflows/regression-tests.yml +++ b/.github/workflows/regression-tests.yml @@ -55,7 +55,7 @@ jobs: pytest -sxvr dragonfly --ignore=dragonfly/replication_test.py - name: Run PyTests replication test timeout-minutes: 15 - if: ${{ inputs.run_replication }} + #if: ${{ inputs.run_replication }} run: | cd ${GITHUB_WORKSPACE}/tests export DRAGONFLY_PATH="${GITHUB_WORKSPACE}/build/dragonfly" # used by PyTests diff --git a/src/server/db_slice.cc b/src/server/db_slice.cc index 1475830aac08..332d3fe2b828 100644 --- a/src/server/db_slice.cc +++ b/src/server/db_slice.cc @@ -302,7 +302,7 @@ pair DbSlice::FindExt(const Context& cntx, string auto& db = *db_arr_[cntx.db_index]; res.first = db.prime.Find(key); - + FiberAtomicGuard fg; if (!IsValid(res.first)) { events_.misses++; return res; @@ -366,7 +366,6 @@ tuple DbSlice::AddOrFind2(const Context& cn if (IsValid(res.first)) { return tuple_cat(res, make_tuple(false)); } - // It's a new entry. for (const auto& ccb : change_cb_) { ccb.second(cntx.db_index, key); @@ -742,6 +741,7 @@ bool DbSlice::CheckLock(IntentLock::Mode mode, const KeyLockArgs& lock_args) con } void DbSlice::PreUpdate(DbIndex db_ind, PrimeIterator it) { + FiberAtomicGuard fg; for (const auto& ccb : change_cb_) { ccb.second(db_ind, ChangeReq{it}); } @@ -854,6 +854,7 @@ uint64_t DbSlice::RegisterOnChange(ChangeCallback cb) { void DbSlice::FlushChangeToEarlierCallbacks(DbIndex db_ind, PrimeIterator it, uint64_t upper_bound) { + FiberAtomicGuard fg; uint64_t bucket_version = it.GetVersion(); // change_cb_ is ordered by vesion. for (const auto& ccb : change_cb_) {