index: Delete old coinstats index directory on startup #36292

Open
fjahr wants to merge 2 commits from 2026-09-coinstats-b-gone into master AGit
fjahr commented 2026-09-17 19:57:18 +00:00 (Migrated from github.com)

coinstatsindex was updated in an incompatible way in v30 (see #30469) and moved to the indexes/coinstatsindex folder. The old indexes/coinstats directory was kept and a warning was logged so users could still downgrade to v29 without resyncing the index.

There was a TODO in the code that scheduled the deletion for v31. Since v32 branch-off has happened, this would now ship in v33. By then 29.x should be EOL assuming we are not going to release a v29.5.

`coinstatsindex` was updated in an incompatible way in v30 (see #30469) and moved to the `indexes/coinstatsindex` folder. The old `indexes/coinstats` directory was kept and a warning was logged so users could still downgrade to v29 without resyncing the index. There was a TODO in the code that scheduled the deletion for v31. Since v32 branch-off has happened, this would now ship in v33. By then 29.x should be EOL assuming we are not going to release a v29.5.
DrahtBot commented 2026-09-17 19:57:25 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
Concept ACK mzumsande
Stale ACK sedited

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

No conflicts as of last run.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36292 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36292.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36292#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | Concept ACK | [mzumsande](https://github.com/bitcoin/bitcoin/pull/36292#pullrequestreview-5241703878) | | Stale ACK | [sedited](https://github.com/bitcoin/bitcoin/pull/36292#pullrequestreview-5245817064) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts No conflicts as of last run. <!--5faf32d7da4f0f540f40219e4f7537a3-->
mzumsande (Migrated from github.com) reviewed 2026-09-17 21:33:40 +00:00
mzumsande (Migrated from github.com) left a comment

Concept ACK

Concept ACK
sedited (Migrated from github.com) approved these changes 2026-09-18 08:31:55 +00:00
sedited (Migrated from github.com) left a comment
ACK 82e4cc6964a9a130d3a41454e046af964ea05508
bartoli commented 2026-09-23 18:52:06 +00:00 (Migrated from github.com)

Shouldn't deletion of the old one be done after the creation of the new one that potentially did not yet occur?
The new one shouldn't need to have the old one to be created, but that 'feels' risky?

Shouldn't deletion of the old one be done after the creation of the new one that potentially did not yet occur? The new one shouldn't need to have the old one to be created, but that 'feels' risky?
fjahr commented 2026-09-23 21:15:28 +00:00 (Migrated from github.com)

Shouldn't deletion of the old one be done after the creation of the new one that potentially did not yet occur? The new one shouldn't need to have the old one to be created, but that 'feels' risky?

This isn't a concern. The new index doesn't use the old version at all. It is incompatible and has been synced from scratch since v30, so the old data is never read from there and so the order doesn't matter.

> Shouldn't deletion of the old one be done after the creation of the new one that potentially did not yet occur? The new one shouldn't need to have the old one to be created, but that 'feels' risky? This isn't a concern. The new index doesn't use the old version at all. It is incompatible and has been synced from scratch since v30, so the old data is never read from there and so the order doesn't matter.
First-time contributor

Earlier concerns remain unresolved; see the Run archive linked from the Review report.

🟠 Minor · Cleanup deletes the legacy index before a pruned upgrade can succeed

For direct v29 upgrades with -coinstatsindex and pruned history, cleanup removes the downgrade fallback before the empty replacement index hits its pre-existing startup failure.

Location: src/index/coinstatsindex.cpp:98 (head).

🔵 Suggestion · Cleanup warnings discard the failing step and filesystem error

When legacy-index cleanup fails, the single warning hides the failing step and discards fs::remove's error, making persistent cleanup failures harder to diagnose.

Location: src/index/coinstatsindex.cpp:101 (head).

🔵 Suggestion · Cleanup tests omit the nonempty-directory failure path

The updated functional test covers only successful deletion, so it would miss startup failures or deletion of unrelated files that occur only when cleanup encounters a nonempty legacy directory.

Location: test/functional/feature_coinstatsindex_compatibility.py:53 (head).

🔵 Suggestion · Cleanup coverage unnecessarily depends on a previous-release binary

The cleanup assertion requires v28.2 despite being independent of legacy records; previous-releases CI includes it, but current-only test runs skip it.

Location: test/functional/feature_coinstatsindex_compatibility.py:55 (head).

Review coverage was incomplete.


Reviewed: 847a312ea5e4 · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:6a916fa059320c1e3f0a79c4f7490636461ad967153b8442c21450419af74010:24633968ff336fb935794e53e586f29b4eaaa2a15575a2c0392a2c8b9ace382c --> <!-- ralph-base:a527a0077a0fcae913188410214efe98021c0cca --> <!-- ralph-head:847a312ea5e44c2c22959c423784c2bb8eb595c1 --> <!-- ralph-case:cbe4926ba969b6f9c4f1fda447c85bb9b879a35e5ffa929e5963d2c6b1146be4 --> Earlier concerns remain unresolved; see the Run archive linked from the Review report. **🟠 Minor · Cleanup deletes the legacy index before a pruned upgrade can succeed** For direct v29 upgrades with `-coinstatsindex` and pruned history, cleanup removes the downgrade fallback before the empty replacement index hits its pre-existing startup failure. Location: [`src/index/coinstatsindex.cpp:98`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/847a312ea5e44c2c22959c423784c2bb8eb595c1/src/index/coinstatsindex.cpp#L98>) (head). **🔵 Suggestion · Cleanup warnings discard the failing step and filesystem error** When legacy-index cleanup fails, the single warning hides the failing step and discards `fs::remove`'s error, making persistent cleanup failures harder to diagnose. Location: [`src/index/coinstatsindex.cpp:101`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/847a312ea5e44c2c22959c423784c2bb8eb595c1/src/index/coinstatsindex.cpp#L101>) (head). **🔵 Suggestion · Cleanup tests omit the nonempty-directory failure path** The updated functional test covers only successful deletion, so it would miss startup failures or deletion of unrelated files that occur only when cleanup encounters a nonempty legacy directory. Location: [`test/functional/feature_coinstatsindex_compatibility.py:53`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/847a312ea5e44c2c22959c423784c2bb8eb595c1/test/functional/feature_coinstatsindex_compatibility.py#L53>) (head). **🔵 Suggestion · Cleanup coverage unnecessarily depends on a previous-release binary** The cleanup assertion requires v28.2 despite being independent of legacy records; previous-releases CI includes it, but current-only test runs skip it. Location: [`test/functional/feature_coinstatsindex_compatibility.py:55`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/847a312ea5e44c2c22959c423784c2bb8eb595c1/test/functional/feature_coinstatsindex_compatibility.py#L55>) (head). Review coverage was incomplete. <!-- Review tier: sensitive --> --- Reviewed: [`847a312ea5e4`](<https://git.fish.foo/bitcoin/bitcoin/commit/847a312ea5e44c2c22959c423784c2bb8eb595c1>) · [Review report](<https://review.fish.foo/report/36292-847a312ea5e44c2c22959c423784c2bb8eb595c1-2667-3.html>) · [Previous reports](<https://review.fish.foo/traces/36292/>) [permalink](<https://review.fish.foo/report/36292-847a312ea5e44c2c22959c423784c2bb8eb595c1-2667-3.html>)
DrahtBot commented 2026-11-02 22:58:46 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
fjahr commented 2026-11-03 15:41:11 +00:00 (Migrated from github.com)

Rebased

Rebased
fanquake (Migrated from github.com) reviewed 2026-11-12 11:23:13 +00:00
fanquake (Migrated from github.com) commented 2026-11-12 11:23:13 +00:00
  requires syncing the index from scratch again. (#36292)
```suggestion requires syncing the index from scratch again. (#36292) ```
fjahr (Migrated from github.com) reviewed 2026-11-13 21:59:21 +00:00
fjahr (Migrated from github.com) commented 2026-11-13 21:59:21 +00:00

Done

Done
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36292
No description provided.