Repository navigation
fix: let offline backups copy without live-work pacing - #1261
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cee71eaf82
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| seen := make(map[string]bool, len(want)) | ||
| tmpDir, err := os.MkdirTemp("", ".ftw-backup-verify-") | ||
| tmpDir, err := os.MkdirTemp(filepath.Dir(archivePath), ".ftw-backup-verify-") |
There was a problem hiding this comment.
Preserve verification for read-only archive locations
When an archive is stored on a read-only USB mount or in a directory the invoking user cannot modify, creating this temporary directory fails even though the archive is readable and the restore destination is writable. Because both Inspect and RestoreContents call Verify, this also prevents inspecting or restoring such backups; use a caller-writable workspace or restrict same-filesystem staging to the creation path.
AGENTS.md reference: AGENTS.md:L24-L25
Useful? React with 👍 / 👎.
| if err := os.MkdirAll(outputDir, 0o700); err != nil { | ||
| return Info{}, fmt.Errorf("backup: create output dir: %w", err) | ||
| } | ||
| if err := state.EnsureDiskSpace(outputDir, state.BackupArchiveScratch(opts.State.BackupSourceBytes(), 0)); err != nil { |
There was a problem hiding this comment.
Include non-database files in the space reservation
When dataDir contains substantial cold Parquet history or other persistent files, this preflight counts only the SQLite state/history files because extraBytes is always zero, while collectSources later adds those files to the archive. A target with room for three copies of a small database but not the cold archive therefore passes the promised refusal check and fills during creation; inventory and include the non-database source sizes before checking free space.
AGENTS.md reference: AGENTS.md:L24-L25
Useful? React with 👍 / 👎.
miravoss26
left a comment
There was a problem hiding this comment.
Reviewed. Fixes #1259: exportHistoryToSQLite always paused 100ms per 1,024 rows and ran under a hardcoded 2h context deadline, even for the read-only offline ftw-backup helper. At the reported 174,629,397-row scale that's 4h44m of pauses alone, so the export always blows the 2h deadline — confirmed with the actual row count in TestBackupArchiveScratchReservesRawGzipAndVerify, which is a nice touch (regression test asserts against the real number from the issue, not a synthetic one).
- Fix:
backupWorkContext()/backupCopyYield()branch onStore.offlineBackup(set byOpenBackupSource) — offline gets no deadline and no yield-pause; live Core backups keep both (100ms pause, 256KiB batches, 2h deadline), so the goal/session-write latency protection this pacing exists for is untouched. - Two related fixes bundled in, both justified by the PR body:
Verifynow extracts beside the archive instead of into process temp (too small for these files on some systems — the test even blocksTMPDIR/TMP/TEMPto prove it doesn't matter anymore), andCreatepreflights disk space (EnsureDiskSpace/BackupArchiveScratch) so a backup that can't fit raw+gzip+verify-extract fails fast instead of partway through. Probe errors (e.g. Windows) don't block — documented and tested (TestEnsureDiskSpaceSkipsUnknownProbe). - Tests: thorough — live-yields/offline-doesn't, deadline presence, disk-space accept/reject/skip-on-error, and a full offline create→verify→restore round-trip checking both a config value and 2,500 history rows survive. CI green across linux amd64/arm64, Windows config ACL, and the full Go suite.
- Security screen: no secrets, no new deps, no new network destinations — pure local file I/O in backup/restore internals.
- PR body is upfront about what's not proven yet (the actual 175M-row dataset, Pi-side
FTW_STORAGE_ADMISSION=1, and #1246 live-backup-vs-goal-latency stays open) — scope is honest, not oversold.
Safe to merge from my read.
OpenBackupSource no longer inherits the live 100ms yield that made a two-hour export deadline unreachable for large converted histories. Live Core backups still pause between copy batches. Verification extracts beside the archive, and create refuses to start without room for the raw export, compressed file and extract. Addresses #1259 Signed-off-by: Fredrik Ahlgren <[email protected]>
…hives Signed-off-by: Fredrik Ahlgren <[email protected]>
9b9bdab to
4e9a899
Compare
Large offline backups inherited a live-work pause and a two-hour timeout, so a sufficiently large history could never finish. The offline helper now skips that pause and deadline while preserving bounded copies and full verification. Live backups keep their existing pacing and durability.
Creation now reserves space for cold Parquet, other saved files, and all database copies that coexist during verification. Restore verifies on its writable target. Standalone verify/inspect prefer the archive filesystem and fall back to normal temporary storage when the source is read-only.
Closes #1259, #1285 and #1286.
Validation:
PATH=/opt/homebrew/bin:$PATH make verifypasses.The real large-dataset offline export and restore remain unproven. #1246 remains open: opt-in Pi IO tests still exceed the two-second durable-goal limit, including one longer control run without a backup. Journal/batch experiments did not establish a safe improvement and are not included. This PR does not claim that all live backup latency is fixed. See #1287 for the separate proposal to store less telemetry history.