recover
Recover persisted log state from store. Call once at startup, before any call to export or merge, and never concurrently with either.
Rebuilds the dedup map from the op-log so that re-export of previously persisted records remains a no-op after a process restart.
If no persisted state exists, the exporter starts with an empty log.
Deliberately not serialized by writeMutex, unlike export and merge. Mutual exclusion here would order the store writes while suggesting a safety it cannot deliver: an un-recovered exporter's segment numbering starts at its construction defaults, so a merge that runs before this returns allocates a segment number the persisted index already uses and overwrites a live key — whichever order the two are serialized in. What makes a pre-recovery call unsafe is the numbering, not the interleaving, so the fix is the contract on this line rather than a lock.
Never throws. The caller installs log capture after awaiting this, so a propagating failure here means capture is never installed at all: the exporter goes silently dead for the whole process lifetime, on every launch, with nothing written and nothing logged (#1860). What a failure costs instead depends on its kind:
An undecodable entry is bad data. The exporter starts fresh.
A refused store call — a throw, or a
CancellationExceptionthe store mints at this live caller from its ownwithTimeout— leaves what is on disk unknown. The exporter fails closed: an export, merge or clear reads again first, or, inside the backoff window below, refuses without reading, and returns ExportResult.Failure and writes nothing while the read is refused. The first read that succeeds installs the persisted log and that turn runs. Starting fresh here instead wrote an index naming only segment 0 over an index this run never read, and the store cannot list keys, so every other segment was lost (#3384).
The re-reads back off, counted in turns: after k refused reads in a row the next min(2^k − 1, 63) turns fail the same way without touching the store, so a long outage costs one store read per 64 turns rather than one per drained batch (#3404). This call is an explicit request, so it always reads, window or not. A read that lands, here or in a turn, closes the window and resets k. One refused here counts toward k like any other. Always reading is not an invitation to call it again to retry: the contract above stands, once and never beside a turn, and the turns do the retrying.
Each guard asks currentCoroutineContext().ensureActive() before treating a throw as a refusal, so a cancellation of the caller's own job still propagates (#3384).