Try wrapping restoreBlocks in a single atomically
#1659
Merged
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.
Issue Number
#1644
Overview
2772f41
📍 Also restore blocks within a single atomic operation.
This is to cope with concurrent requests that could come at the same
time we are restoring blocks and would modify the internal state
associated with checkpoints. Here's a scenario of interleaved actions
in different threads:
a) Thread 1: 'restoreBlocks' is triggered and fetch
cp0
from the database.b) Thread 2: A request for creating an address is received. We fetch
cp0
c) Thread 1: Blocks are restored, and new checkpoints are created from
cp0
d) Thread 2: A new address is added, and
cp0
is replaced bycp0'
e) Thread 1:
cp1
...cpN
are inserted, but they're all missing the address fromcp0'
!A side-effect of this is that it will make the restore block operation
blocking for longer, which could possibly be an issue in restoration
mode where requests are consumed in a fast pace. Concurrent requests
will likely be slower.
Co-Authored-By: @Anviking
edited by @KtorZ