Skip to content

Replace previous database index snapshots atomically - #668

Open
betacatsling wants to merge 3 commits into
treeverse:mainfrom
betacatsling:fix/index-snapshot-replacement
Open

betacatsling wants to merge 3 commits into
treeverse:mainfrom
betacatsling:fix/index-snapshot-replacement

Conversation

@betacatsling

@betacatsling betacatsling commented Sep 12, 2026

Copy link
Copy Markdown

write_db() updates entries but never removes keys absent from the new index. Rewriting a snapshot therefore resurrects deleted files on read_db().

Clear the previous contents inside the existing transaction before serializing the new index. Tests cover replacement, an empty snapshot, and rollback when lazy index iteration fails after yielding an entry. The two replacement regressions fail on the unchanged base; rollback remains intact.

Validation on Linux/Python 3.12: 194 tests passed, 32 skipped; Ruff format/lint, project mypy and diff checks passed. The tests use a real temporary database. AI assistance was used for implementation and verification.

Prerequisite and revalidation: this branch now includes the shared CLI compatibility fix in #672 (4551489) followed by the original focused patch. This lets a fresh [tests,cli] installation run without external Click. The common change is separately reviewable and will disappear from this PR's diff once #672 is merged.

Revalidated the combined branch on Python 3.12 / Typer 0.27.2 with external Click absent: 200 passed / 32 skipped, mypy passed, and full source/test lint plus formatting passed with the repository-pinned Ruff 0.15.2. The benchmark workflow's base-branch step still needs #672 merged to main; it runs before the PR's code.

Fixes #667.

@github-project-automation github-project-automation Bot moved this to Backlog in DVC Sep 12, 2026
@codecov

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.24%. Comparing base (e38c8c2) to head (122dfd8).
⚠️ Report is 72 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #668      +/-   ##
==========================================
+ Coverage   72.42%   74.24%   +1.82%     
==========================================
  Files          67       67              
  Lines        5132     5425     +293     
  Branches      605      624      +19     
==========================================
+ Hits         3717     4028     +311     
+ Misses       1227     1203      -24     
- Partials      188      194       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@betacatsling
betacatsling force-pushed the fix/index-snapshot-replacement branch from 6d06b01 to 122dfd8 Compare September 12, 2026 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rewriting an index database retains entries from the previous snapshot

1 participant