Skip to content

Issue 4900: Read LAC from EntryMemTable in SortedLedgerStorage if it is missing from the Ledger Cache - #4902

Open
djsweet wants to merge 3 commits into
apache:masterfrom
djsweet:djsweet/sorted-ledger-storage-read-lac-from-memtable
Open

djsweet wants to merge 3 commits into
apache:masterfrom
djsweet:djsweet/sorted-ledger-storage-read-lac-from-memtable

Conversation

@djsweet

@djsweet djsweet commented Oct 4, 2026

Copy link
Copy Markdown

Descriptions of the changes in this PR:

Main Issue: #4900

Note that there is a separate issue, #4895, that must be addressed for this to function correctly when ledger metadata is in use.

Motivation

The root cause of #4900 is that SortedLedgerStorage ignores EntryMemTable when getting the LAC. This PR updates SortedLedgerStorage so that the LAC is read from EntryMemTable if it is missing in the LedgerCache.

Changes

  • In EntryMemTable, expose a getLastAddConfirmed that functions similar to InterleavedLedgerStorage.getLastAddConfirmed.
  • Refactor InterleavedLedgerStorage.getLastAddConfirmed to expose getLastAddConfirmedFromLedgerEntry, the LAC reading case where the LAC is not present in the Ledger Cache
  • In SortedLedgerStorage.getLastAddConfirmed, first explicitly try to read the LAC from InterleavedLedgerStorage's LedgerCache. If the LAC isn't present in the ledger cache, read it from the EntryMemTable. If the LAC isn't present in the EntryMemTable, read it from InterleavedLedgerStorage directly, bypassing the LedgerCache.

The internals of getLastAddConfirmed for EntryMemTable are similar
to the implementation in InterleavedLedgerStorage. This will eventually
be consulted in SortedLedgerStorage to retrieve the LAC.
This method will eventually be used within SortedLedgerStorage as
a last-try attempt to read the LAC, with additional logic between
checking the ledger cache and reading an entry from the filesystem.
SortedLedgerStorage.getLastAddConfirmed now falls back to the EntryMemTable
for LAC if it is not present in the ledger cache of its internal
InterleavedLedgerStorage. This fixes an issue where accumulating low-data
or empty ledgers can cause ledgers to fall out of the ledger cache, but
still be present in the memtable and therefore not flushed, to report
the ledger as missing when acquiring the LAC for the ledger.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant