Guard loadRecord, deleteRecord, and saveRecord behind AsyncLocks - #4523
Open
alecgrieser wants to merge 6 commits into
Open
Guard loadRecord, deleteRecord, and saveRecord behind AsyncLocks#4523alecgrieser wants to merge 6 commits into
loadRecord, deleteRecord, and saveRecord behind AsyncLocks#4523alecgrieser wants to merge 6 commits into
Conversation
alecgrieser
force-pushed
the
04522-async-lock-records
branch
from
August 27, 2026 14:01
94c760a to
10b51ff
Compare
alecgrieser
force-pushed
the
04522-async-lock-records
branch
from
September 1, 2026 15:18
62bab54 to
2531af3
Compare
alecgrieser
marked this pull request as ready for review
September 1, 2026 15:41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This introduces a new
StoreConcurrencyManagerinterface. This is designed to help theFDBRecordStoremanage its intra-transaction operations. For the moment, that means making sure that reads and writes to the same individual records do not interfere, though we can increase the level of protection in the future by adding things like additional levels of locking. For example, we could add a second lock that is shared by all multi-record operations, and then each operation needs to grab a shared or exclusive lock depending on what the operation is. However, we do need to a be a little careful there to avoid deadlocks, as our locking framework is not currently re-entrant.Note that we already had an
AsyncLockframework, so the work in this PR is really just to:FDBRecordStore.This also introduces a no-op implementation. By default,
FDBRecordStores opt in to the new behavior. That's a little bit unorthodox, but given that this is a safety feature, it seems like a good idea to op people in to the safe behavior, and then they can escape back to the old behavior if they really need to.Caution: There was one place where enabling this was found to have an issue, and it's in the
SlidingWindowIndexMaintainer. That index maintainer (uniquely) can read a record as part of its maintenance. This means that we can end up in a deadlock, if there are two concurrent saves, and one of them is to the record that is currently the boundary between in-the-window and out-of-the-window. Users of sliding window indexes may therefore need to disable this feature until it can be made more robust.This resolves #4522