1
0
Fork 0
mirror of https://github.com/dragonflydb/dragonfly.git synced 2024-12-14 11:58:02 +00:00

feat(db slice): add fiber atomic gaurd (#878)

Signed-off-by: adi_holden <adi@dragonflydb.io>
This commit is contained in:
adiholden 2023-02-26 13:38:37 +02:00 committed by GitHub
parent 4b44fb6baf
commit 6a2b152e8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View file

@ -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

View file

@ -302,7 +302,7 @@ pair<PrimeIterator, ExpireIterator> 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<PrimeIterator, ExpireIterator, bool> 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_) {