Skip to content

Preserve backup file identity during cleanup and retention - #698

Merged
matteius merged 5 commits into
mainfrom
fix/database-backup-identity
Nov 1, 2026
Merged

matteius merged 5 commits into
mainfrom
fix/database-backup-identity

Conversation

@matteius

@matteius matteius commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #701; merge the shared CI cleanup first. This branch includes that exact shared commit so its workflow changes disappear from this PR after #701 merges. Suite membership is declared beside the tests in CMake; this fix has no independent workflow edits. All three remaining fix branches merge cleanly with each other.

Backup cleanup and retention could delete a replacement file after selecting a pathname. Retention also reopened names after sorting, losing the identity of the selected backups.

Hold file and directory descriptors through selection and deletion. Move selected entries into a private directory without replacing existing entries, verify their identity there, and restore or retain uncertain files. Abort retention before deletion if the full inventory cannot be collected.

  • After the shared CI cleanup merges, four files: one production file, two regression suites, and their CMake registrations.
  • Independently on main: 35 of 48 cases fail before the fix; all 48 pass with ASan/UBSan afterward. Tests use private temporary trees and cover replacements, symlinks, allocation/descriptor failures, restoration conflicts, and normal cleanup/retention.
  • Run: ctest --test-dir build/focused-debug --output-on-failure -R '^test_db_backup_(cleanup|retention_identity)$'.

Retention temporarily uses one descriptor per eligible backup. Atomic no-replace moves require Linux/filesystem support; unsupported operations retain files and report incomplete cleanup. Uncertain artifacts may require manual recovery. Held descriptors do not prevent another writer from modifying an already-open inode.

Extracted independently from #693; no foundation framework or policy exceptions. Hosted CI is required before merge.

Revalidated after updating from main and adopting the shared CI suites: focused ASan/UBSan regressions pass, and CTest labels select the existing suite plus only this PR’s regressions.

Pin selected backup files and their parent directory through stale cleanup
and retention deletion. Move verified candidates into a private quarantine
without overwriting competing entries; retain changed or uncertain files
and restore failures for recovery. Reject duplicate selection names and
fail collection before deletion when descriptors or memory are unavailable.

Add 48 real-filesystem regression cases and register them in the existing
unit build and integration/sanitizer jobs. On origin/main 8927bc8, cleanup
fails 22/29 cases and retention fails 13/19; the isolated fix passes all
48 under Debug ASan/UBSan. Tests use owned temporary trees, without services
or legacy shared-path fixtures. Unsupported atomic filesystem operations
fail conservatively; this does not protect against privileged external
writers mutating held inodes.
@codecov

codecov Bot commented Oct 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.27891% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/database/db_core.c 97.27% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@matteius
matteius merged commit e174b44 into main Nov 1, 2026
13 checks passed
@matteius
matteius deleted the fix/database-backup-identity branch November 1, 2026 00:17
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.

1 participant