Skip to content
Open
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
11 changes: 7 additions & 4 deletions src/server/db_slice.cc
Original file line number Diff line number Diff line change
Expand Up @@ -683,12 +683,15 @@ OpResult<DbSlice::ItAndUpdater> DbSlice::AddOrFindInternal(const Context& cntx,
auto status = res.status();
CHECK(status == OpStatus::KEY_NOTFOUND || status == OpStatus::OUT_OF_MEMORY) << status;

// Call change callbacks on the computed set of buckets that can be affected by the insert
if (!change_cb_.empty()) {
auto bucket_set = db.prime.CVCUponInsert(key);
CallChangeCallbacks(cntx.db_index, bucket_set);
for (bool consistent = false; !consistent;) {
Copy link
Copy Markdown

@augmentcode augmentcode Bot May 4, 2026

Choose a reason for hiding this comment

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

src/server/db_slice.cc:688 — This retry loop has no bound, so if CVCUponInsert(key) keeps changing due to concurrent activity while callbacks block/yield, AddOrFindInternal could potentially livelock and never proceed to the actual insert. Consider adding some guard/guarantee (or documenting the convergence invariant) to ensure termination.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Eventually all possible buckets will be visited, which implies no suspension will occur and the operation will finish

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll add that as a comment

auto bucket_set = db.prime.CVCUponInsert(key);
CallChangeCallbacks(cntx.db_index, bucket_set);

// Set of possible insertion buckets must be the same after possibly blocking call
DCHECK(bucket_set == db.prime.CVCUponInsert(key));
// Repeat the change callbacks if the target set changed
consistent = (bucket_set == db.prime.CVCUponInsert(key));
}
Comment on lines +688 to +694
}

ssize_t memory_offset = -key.size();
Expand Down
Loading