Coin Brief ENDE

A rippled fix proposes ending a five-second cache lock that dropped busy nodes from full to syncing

XRP Ledger servers that use online_delete to keep their disk usage in check periodically rotate their node store: the oldest backend is deleted, the current one becomes the archive and a new one is opened. A pull request opened on 2 December, #8810, says a step in that rotation has been knocking busy nodes out of sync, and proposes a fix. It is still open and not yet merged. Its author, ximinez, describes it as a fork of an earlier pull request, #8240, by pratikmankawde.

Before the archive is deleted, a step called the freshen re-reads every key in the in-memory cache of ledger tree nodes, so that anything stored only in the archive is copied forward and survives. A busy mainnet node holds tens of millions of such nodes. The freshen gets its keys from TaggedCache::getKeys(), which copies all of them while holding the cache's mutex, and every job that needs the cache waits.

A rippled fix proposes ending a five-second cache lock that dropped busy nodes from full to syncing
A rippled fix proposes ending a five-second cache lock that dropped busy nodes from full to syncing — Coin Brief

According to the pull request this has been the case since online_delete was added in 2014, and the hold grows with the cache. On mainnet nodes it was measured at more than five seconds per rotation. A ledger closes about every four seconds, so a close always falls inside the hold, and consensus jobs wait for it. On one node, every such hold was followed within seconds by a drop from full to syncing.

The proposed change adds forEachKeyPartition. The cache is already split into one partition per hardware thread, and the new method copies the keys of one partition at a time and runs the fetches with the mutex released, so the longest hold is one partition rather than the whole cache. The pull request explains why a walk that no longer sees the whole cache at one moment is still safe, and why two alternatives were rejected: removing the freshen would lose nodes stored only in the archive, and the node store has no call that checks a key without reading it.

Primary source
rippled repository
https://github.com/XRPLF/rippled/pull/8810