Skip to content

Conversation

@amesgen
Copy link
Member

@amesgen amesgen commented Jun 10, 2025

Closes #1551

The commits are intended to be reviewed individually.

amesgen added 3 commits June 10, 2025 17:27
Hold a read lock while getting and duplicating the anchor handle, such that the
handle can not be closed in between.

Also make sure to close the duplicated handle.
This reverts commit 7900088.

Without the fix in the preceding commit, this would cause test failures, see

    cabal run ouroboros-consensus-diffusion:mock-test -- \
      --quickcheck-replay="(SMGen 15972426649573867634 4412022096428701771,88)" \
      -p '/Praos.simple convergence/'
No behavioral change, just a refactoring by extracting common parts; convenient
for follow-up changes
amesgen added 2 commits June 10, 2025 17:36
No behavioral change, purely a refactoring
Not necessary given how it is currently being used, but it is also easy enough
to make it resilient against the race condition, so why not?
@amesgen amesgen force-pushed the amesgen/ledgerdb-v2-locking branch from 19faf20 to 4010598 Compare June 10, 2025 17:54
@amesgen amesgen added this pull request to the merge queue Jun 11, 2025
Merged via the queue into main with commit 8e16ce0 Jun 11, 2025
19 checks passed
@amesgen amesgen deleted the amesgen/ledgerdb-v2-locking branch June 11, 2025 09:07
@jasagredo jasagredo moved this to ✅ Done in Consensus Team Backlog Jun 13, 2025
amesgen added a commit that referenced this pull request Jun 30, 2025
Closes #1551

The commits are intended to be reviewed individually.

- The first commit fixes the race condition described in #1551 by using
the `ldbOpenHandlesLock` to duplicate the handle when snapshotting.
- The second commit reverts 7900088
added in #1516, enabled by the first commit. Without the first commit,
this would cause test failures, see the commit description.
- The third and fourth commits are purely refactorings to be able to
reuse the pattern of "duplicating while holding a read lock".
- The fifth commit uses the same pattern for `takeSnapshotNOW`, a
testing function, see the commit description.
 - The last commit adds documentation for `ldbOpenHandlesLock`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

LedgerDB V2: prevent race conditions between using (duplicating) and closing LedgerTableHandle s

3 participants