borgbackup / borgbackup/borg

check: make the pre-check index/key rebuild phases interruptible (remaining work for #7893)

Open
#10,042 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
13.7k
Forks
875
Avg merge
13h 24m
Merged PRs (30d)
183

Description

#9966 makes `borg check` respond to Ctrl-C during the repository pack loop and between archives in the archive check. Two earlier phases still ignore the signal, so on a large `--repair` the first Ctrl-C can look like it did nothing until those phases finish. This is the remaining work to fully close #7893.

Two spots don't poll `sig_int`:

1. `build_chunkindex_from_repo(..., slow_rebuild=True)` (cache.py) rebuilds the chunk index by reading every pack's object headers, in the loop over `repository.store_list("packs")` at cache.py:876. `--repair` always takes this slow path, and on a repo with many packs it runs for a long time before any check code is reached.

2. `ArchiveChecker.make_key()` (archive.py:1951) falls back to reading up to 999 chunks to recover the key when the manifest is unreadable (archive.py:1967).

Unlike the pack loop, a half-built chunk index can't be saved and resumed: it would be missing chunks and report them as lost. So these phases must raise on interrupt rather than stop and persist.

Secondary, same area: `ArchiveChecker.rebuild_archives()` only breaks between archives. That's correct for `--repair`, which rewrites each archive as a whole, but a read-only check could break inside the item loop for faster response on a single very large archive. Worth branching on `repair`.

Contributor guide

Open the contributing guide

Research direction

Start in cache.py at build_chunkindex_from_repo(..., slow_rebuild=True) and the repository.store_list("packs") loop, then inspect ArchiveChecker.make_key() and rebuild_archives() in archive.py. Run the relevant borg check tests or a large --repair/read-only check with Ctrl-C. Done means both early phases respond promptly by raising, with no partial chunk index persisted, while read-only archive checking can interrupt inside an item loop.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.