ingest/ledgerbackend: fix to ensure that the ledger buffer properly queues the last batch of ledgers (LCM) within the specified range #5563
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.
PR Checklist
PR Structure
otherwise).
services/friendbot
, orall
ordoc
if the changes are broad or impact manypackages.
Thoroughness
.md
files, etc... affected by this change). Take a look in the
docs
folder for a given service,like this one.
Release planning
CHANGELOG.md
within the component folder structure. For example, if I changed horizon, then I updated (services/horizon/CHANGELOG.md. I add a new line item describing the change and reference to this PR. If I don't update a CHANGELOG, I acknowledge this PR's change may not be mentioned in future release notes.semver, or if it's mainly a patch change. The PR is targeted at the next
release branch if it's not a patch change.
What
The fix updates the boundary check in bounded mode to ensure the
BufferedStorageBackend
/LedgerBuffer
queues ledgers up to the end boundary ledger of the specified range. This fixes an issue where the final batch of ledgers is skipped in scenarios where multiple ledgers are stored per file and thefrom
ledger does not align with the start boundary of the stored file.Why
This issue occurs only in bounded mode where multiple ledgers are stored per file.
For example:
When
ledgers_per_file
is set to 4, each file contains 4 consecutive ledgers, resulting in files like:0–3.xdr
,4–7.xdr
,8–11.xdr
,12–15.xdr
,16–19.xdr
and so on.Suppose we need to fetch ledgers
6 to 17
using theBufferedStorageBackend
, so thefrom
ledger is6
andto
ledger as17
:LedgerBuffer
starts by downloading the file containing ledger6
(4–7.xdr
).ledgers_per_file
), fetching the batch containing ledger10
and14
resulting in the download of files8–11.xdr
and12–15.xdr
.18
, it exceeds theto
ledger (17
).At this point, the buffer stops queuing, skipping file
16–19.xdr
even though it contains ledger17
which is part of the requested range.When
GetLedger
is called, theBufferedStorageBackend
first checks if the current LCM object contains the requested ledger. If not, it tries to fetch the next LCM object from theLedgerBuffer
. Since16–19.xdr
was never queued due to the boundary check,GetLedger
blocks indefinitely when called for ledger16
or later, waiting for a ledger that is never queued.This issue does not trigger an error log because it is not treated as a failure which causing the system to remain in wait state.
Known limitations
N/A