Skip to content

fix(core-storage): copy history.db into a name that does not exist yet - #4564

Merged
datlechin merged 2 commits into
mainfrom
fix/core-storage-vacuum-into-target
Nov 26, 2026
Merged

datlechin merged 2 commits into
mainfrom
fix/core-storage-vacuum-into-target

Conversation

@datlechin

@datlechin datlechin commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Summary

  • keep_database no longer makes an empty .partial before VACUUM INTO. SQLite creates the file, under a name that is free.
  • New vacuum_into_new_file refuses a target that already exists before SQLite sees it, then sets the new copy to 0600. The SQLite docs allow an existing empty target (VACUUM INTO). Apple's 3.54.0 in macOS 27 and the iOS 27.1 SDK refuses it ("output file already exists"), and upstream writes into it. With the check, every SQLite build behaves the same.
  • The folder is set to 0700 first, so the file SQLite makes from the umask is never readable by another user before it is set to 0600. The leftover cleanup, sync, rename and directory sync are unchanged.
  • Upstream never changed this rule: src/vacuum.c still refuses only size > 0 in 3.54.1, and the 3.54.0 release notes do not mention VACUUM. Apple's build (source id ending aapl, dated 2026-04-09) refuses an existing target whether it is empty or not, with defensive mode on or off.
  • linux/docs/storage.md, Copies before a format upgrade: describes the new staging.
  • No app shows this today, so there is no changelog fragment. The Apple apps open the core with storageDir: nil. Linux (Ubuntu 26.04 and 26.10, Fedora 44 and 45, GNOME 51 Flatpak) and Windows (bundled 3.54.1) all accept the empty file. Without this fix, a core-backed history on macOS 27 or iOS 27 would fail to open after every upgrade that adds a migration.

Test plan

  • New upgrade_copies::tests::the_copy_step_takes_only_a_name_that_is_free: an existing empty target is refused and left at 0 bytes, on every SQLite build. A free name gets a 0600 copy that holds the schema.
  • On main on macOS 27 (system SQLite 3.54.0): 16 tablepro-storage tests fail with "output file already exists". With this change, all 373 pass.
  • Linux dev container (Ubuntu 26.04, SQLite 3.46.1), verify.sh --platform linux --jobs 4: test tablepro-storage passes 383 of 383, and lint is clean. The full test was INCONCLUSIVE twice: the 8 GB Docker VM OOM-killed rustc on the app's lib test before any suite ran. CI's Linux fast checks run that suite.
  • macOS: cargo clippy -p tablepro-storage --all-targets -- -D warnings is clean.
  • C probe of VACUUM INTO on a missing target, an empty file and a non-empty file. Apple 3.54.0 accepts only the missing target. Upstream 3.51.3 and 3.54.1 accept the missing target and the empty file.

@datlechin
datlechin enabled auto-merge (squash) November 25, 2026 19:52
@datlechin
datlechin merged commit 08bdd75 into main Nov 26, 2026
33 of 34 checks passed
@datlechin
datlechin deleted the fix/core-storage-vacuum-into-target branch November 27, 2026 16:37
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