Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/regression-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to run replication pytests again in regression tests

#if: ${{ inputs.run_replication }}
run: |
cd ${GITHUB_WORKSPACE}/tests
export DRAGONFLY_PATH="${GITHUB_WORKSPACE}/build/dragonfly" # used by PyTests
Expand Down
5 changes: 3 additions & 2 deletions src/server/db_slice.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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});
}
Expand Down Expand Up @@ -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_) {
Expand Down