indexes: Save progress on early flushes

bitcoin/bitcoin: PR #36948

The review is inconclusive; no findings were published.

Coverage details

Background

Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.

Documented decisions

Auxiliary-index persistence was deliberately separated from in-memory progress to mirror infrequent block-index flushing. Jim Posen explained that BlockConnected could advance the index without guaranteeing that corresponding block-index entries were durable; delaying the persistent best-block marker also avoided taking cs_main to construct a locator on each BlockConnected callback.

This explains why an index can legitimately have processed more blocks than its saved progress records. Historically, crash recovery could replay work from an older saved point, with avoiding corruption taking precedence over preserving every increment of progress. It supplies the durability and performance context for committing on flush notifications rather than on every connected block.

Source 1