Swap: retry a journal's recovery checkpoint while idle

After a lost record the journal drops position-based records until a
full checkpoint. That checkpoint was only requested from later edits,
rate-limited to once a second; when the writer handled the failing
record before its edit asked for a checkpoint, the checkpoint failed as
well and consumed the slot, so edits made within the next second were
not recovered and, if the user stopped typing, the journal stayed behind
indefinitely. SwapManager::RetryGapCheckpoints(), called once per frame
from Editor::ProcessPendingOpens, requests it once the interval has
passed. This also made SwapReplay_LostRecord_ResyncsWithCheckpoint flaky
under load; the test now exercises the retry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015rcVQiiWyTzoNrsvLSaAfB
This commit is contained in:
Claude
2026-09-24 09:16:04 -07:00
committed by Kyle Isom
parent b1b0b3de57
commit 1e312fcd0b
5 changed files with 46 additions and 0 deletions
+7
View File
@@ -80,6 +80,13 @@ public:
// This is best-effort and asynchronous; call Flush() if you need it written before continuing.
void Checkpoint(Buffer *buf = nullptr);
// Main thread, called once per frame: request the recovery checkpoint of
// any journal left with a gap (a lost record) whose last attempt is more
// than the retry interval ago. Otherwise that checkpoint is only
// requested by the next edit, and a journal that lost a record just
// before the user stopped typing would stay behind indefinitely.
void RetryGapCheckpoints();
void SetConfig(const SwapConfig &cfg)
{