db/snapshotsync/freezeblocks: run block-snapshot merge off the shared build semaphore#21526
Draft
sudeepdino008 wants to merge 1 commit into
Draft
db/snapshotsync/freezeblocks: run block-snapshot merge off the shared build semaphore#21526sudeepdino008 wants to merge 1 commit into
sudeepdino008 wants to merge 1 commit into
Conversation
… build semaphore Block retire held the shared snapshot-build semaphore across both the dump and the slow, expensive merge, blocking state-snapshot collation/prune for the merge's full duration. Release the semaphore after the dump and run the merge in its own goroutine (mirroring the aggregator's MergeLoop). The fast dump stays serialized against state building; the slow merge no longer starves state collation.
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.
Problem
Block retirement holds the shared snapshot-build semaphore (
snBuildAllowed, default size 1) across both the fast dump and the slow, expensive block-segment merge. While a large block merge runs, state-snapshot collation/prune (which bounds chaindata growth) is blocked for the merge's full duration.Observed on a minimal node: an 8.2 GB / ~19-minute
025100→025200transactions merge held the semaphore the whole time, starving state collation —stepsInDBclimbed to 3.82 (chaindata bloats while collation waits).Change
Release the semaphore after the dump phase and run the merge in its own goroutine, off the semaphore — mirroring how the aggregator runs
MergeLoop. The fast dump stays serialized against state-snapshot building (preserving the I/O-throttle intent); the slow merge no longer starves state collation.Effect
With the same 8.2 GB block-tx merge in flight, state collation now proceeds concurrently —
stepsInDBstays < 2 (was 3.82). The CLIretirepath callsMergeBlocksexplicitly so its behavior is unchanged.Tests
TestBlockMergeRunsWithoutSemaphore— merge completes while the semaphore is fully held (regression-guards re-acquisition).TestRetireBlocksInBackgroundReleasesSemaphore— background retire releases the semaphore, no leak.Draft — full
make lint+ integration verification pending.