Skip to content

Post-processing trusts live PAR's verified set: no second par verify, par2 index loaded once - #739

Merged
xbmc4lyfe merged 1 commit into
mainfrom
live-par-trust-postproc
Nov 27, 2026
Merged

xbmc4lyfe merged 1 commit into
mainfrom
live-par-trust-postproc

Conversation

@xbmc4lyfe

@xbmc4lyfe xbmc4lyfe commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

What

6790 audit (prybar rgstream report) finding 3 and finding 7: after live PAR has verified or repaired the whole set, post-processing still ran a full par verify, and loaded the par2 index again and again.

Cause. Par-rename is handed the first-16-KiB MD5 that the download computed for each file. The queue stores that hash nzbget-style: the bytes in reverse order, as upper-case hex. It was parsed as if it were in digest order, so every known hash was reversed and matched nothing. Par-rename then reported every file "missing" and requested a par-check, on clean sets too (6790 job 3102, harness repro on main). parrenamer::parse_printed_hash16k reads it back in digest order.

Trust live PAR. Post-processing now skips the par-check when live PAR has a complete verified state. That needs all of the following:

  • a current session on the download folder, with trusted slices
  • every slice verified (or rebuilt and verified): none diverged, no fold pending, no rebuilt slice waiting for its recheck
  • no file outside the recovery set
  • every file under its par2 name and at its par2 length, and it is the queue file whose bytes live PAR verified
  • no file changed since post-processing first looked (inode, length and mtime are sealed at the start of post-processing)
  • one par2 set in the folder
  • ParCheck=auto, not post-processing again, and no unpack tried and no forced check or repair. So a failed unpack still gets a real par-check.

When all of that holds, the job gets what nzbget stores after a quick par-check that needed no repair: ParStatus SUCCESS and par_full 0. The stream-repair jobs of the verified files are erased, as register_verified_file does. If any condition fails, the normal par-check runs and the detail log says why.

Par2 index. Post-processing now loads the par2 index once, in par-rename. The par-check used to load the index and every recovery volume again.

Tests

  • Unit (parchecker/live_trust_tests.rs): the cover needs every slice verified, ends when a file changes (another inode, or a shorter file), needs trusted slices and a current session, and needs the file live PAR verified (binding cases). Also parrenamer::printed_hash16k_reads_back_in_digest_order.
  • Harness, using a RAR set with the production options:
    • liveparrarclean: no par-check, no missing volumes, one par2 load, ParStatus NONE.
    • liveparrartrust: lost and corrupt articles, direct unpack stops, live repair at download end. No par-check lines, no missing volumes, one par2 load, the trust line, SUCCESS / ParStatus SUCCESS / UnpackStatus SUCCESS, byte-exact.
    • liveparraroff (control): the same damaged set with live PAR off. The par-check runs and is seen (Verifying lines, at least 2 par2 loads, "Successfully repaired"), with the same statuses.
  • Before (main ba93ae1, farm): liveparrarclean FAIL (par_check_lines=2, missing_lines=8, ParStatus SUCCESS); liveparrartrust FAIL (par_check_lines=2, missing_lines=6).

Validation

Final head 4b3f599, on main 2321559. The range-diff against 418981d and ea31180 is "=". GitHub Actions is unavailable, so the farm runs replace it.

Farm job for 4b3f599:

x86_64: cargo_exit=0   (cargo test --tests -- --test-threads=12 on rustyget-x86-d, 109s)
x86_64: daemon_exit=0   (just test-daemon on rustyget-x86-d, 45s)
x86_64: 439 / 440 scenarios passed on target=local
        [FAIL] truncatedstate (nzbget did not become ready): first run on rustyget-x86-a; rerun alone on rustyget-x86-d: PASS => FLAKY under load
arm64:  cargo_exit=0   (cargo test --tests -- --test-threads=12 on rustyget-arm-a, 159s)
arm64:  daemon_exit=0   (just test-daemon on rustyget-arm-a, 45s)
arm64:  440 / 440 scenarios passed on target=local

macOS (m5air, same patch at 418981d): cargo_exit=0. The rest of that run was still queued when this was merged. macOS is not in the merge gate for this change: it has no platform-specific code beyond the existing cfg(unix) FileStamp.

Earlier heads:
Head 418981d, on main 3471984. GitHub Actions is unavailable, so the farm runs replace it.

Farm job farm-val-418981d0-1795742840dpch:

x86_64: cargo_exit=0   (cargo test --tests -- --test-threads=6 on rustyget-x86-d, 132s)
x86_64: daemon_exit=0   (just test-daemon on rustyget-x86-d, 47s)
x86_64: 437 / 438 scenarios passed on target=local
        [FAIL] watchswaptwin: first run on rustyget-x86-b 125s; rerun alone on rustyget-x86-d: PASS => FLAKY under load
arm64:  cargo_exit=101 (cargo test --tests -- --test-threads=7 on rustyget-arm-c, 121s)
        [cargo FAIL] parlive::physical_ownership_tests::intermediate_root_alias_cannot_bypass_a_certified_target: rerun alone PASS => FLAKY under load
arm64:  daemon_exit=0   (just test-daemon on rustyget-arm-c, 45s)
arm64:  438 / 438 scenarios passed on target=local

The same patch on f1be381 (head ea31180; range-diff "=") had no failures:

x86_64: cargo_exit=0, daemon_exit=0, 436 / 436 scenarios passed
arm64:  cargo_exit=0, daemon_exit=0, 436 / 436 scenarios passed

Earlier head 6e64b1c on m5air: cargo_exit=0 (1602 passed), daemon_exit=0.

Deployed on 6790

  • Build: eac9eba6, which is deploy-6790 a744b528 plus this PR at ea31180. Deb rustyget_0.1.0+git20261127004343.eac9eba6_amd64.deb, sha256 5dbb5e24a5793b764c16d63d3100ac4a9c4cd0dcac58ffffc25e0bc3e6dac5be.
  • Health: the service is active with NRestarts 0. The Server* block in /var/lib/rustyget/rustyget.conf is unchanged (cmp equal, 187 Server lines).
  • Measurement set: LEE 3.3 GB 7z (634 slices) on real providers, in two versions: clean, and with 12 dead segments.
  • Method: one sample of each. The server was busy, so step times are noisy. For the before runs, the previous build a744b528 was put back temporarily.
  • Raw results: server:~/rgtest/lpt/run-before-20261127T011431Z and run-after-20261127T010129Z.
run par-rename "missing" + par-check PostTotalTimeSec ParStatus
clean, before yes: "Requesting par-check/repair ... to restore missing files", Verifying, Repair not needed 44 s SUCCESS
clean, after none 22 s NONE (nzbget's value for a clean auto download)
damaged, before yes 31 s SUCCESS
damaged, after none: "Skipping par-check for LPT-after-dmg: live PAR verified every file of q4hDDQN3ezX5cgGyO.par2 (7 file(s) ...)" 3 s SUCCESS
  • The par-check stage itself took 6 to 8 s on this set: the files had already been quick-verified, so it read little. The rest of the before/after difference is server load.
  • In the damaged after-run, the time from download end to history was still 50 s. All of it was live PAR before post-processing started: waiting for recovery volumes, then a 24.3 s live repair. This PR does not change that part.

Follow-up (not in this PR)

Live PAR's live_hash16k callers also receive the queue's printed hash: articledl.rs 832/843/2210/2594/2723 and queuecoord.rs 3704/4026/4057. Hash-based binding there never matches, and bind() may invalidate the namespace on renamed sets. The trust decision here rests on per-slice par2 checksums, not on those hashes.

Review

🤖 Generated with Claude Code

https://claude.ai/code/session_01LG44gYUGuwLMB2hw7HQGbM

@xbmc4lyfe
xbmc4lyfe force-pushed the live-par-trust-postproc branch 3 times, most recently from ea31180 to 418981d Compare November 27, 2026 01:27
… par2 index loaded once

The 6790 audit (finding 3) saw par-rename report every volume missing after live PAR had
verified or repaired the whole set, request a par-check, verify every file again and log
"Repair not needed" (1.0x the set re-read, most of the 26-50 s tail on damaged 4 GiB sets).

Cause: par-rename is handed the first-16-KiB MD5 the download computed for each file, but the
queue stores it printed the nzbget way (bytes last to first). It was parsed in digest order,
so every known hash was reversed and matched nothing: every file was "missing", on clean sets
too (6790 job 3102). parrenamer::parse_printed_hash16k reads it back in digest order.

Then, when live PAR has a complete verified state of the set, the par-check is not run:
parchecker::streaming_session_verified_cover requires a current session on the download
folder with trusted slices, every slice verified (or rebuilt and verified, rechecks done),
none diverged, no fold pending, no file outside the recovery set, every file under its par2
name at its par2 length, the queue file whose bytes live PAR verified, and unchanged since
post-processing first looked (inode, length, mtime). prepost takes it where the par-check
would start (ParCheck=auto, health below 100% or a requested check; never after an unpack,
for a forced check or repair, or a post-process again) and stores what nzbget stores after a
quick par-check that needed no repair (ParStatus SUCCESS, par_full 0), erasing the
stream-repair jobs of the verified files. Otherwise the normal par-check runs and the detail
log says why.

Post-processing now loads the par2 index once (par-rename); the par-check loaded the index
and every recovery volume again.

Harness: liveparrarclean, liveparrartrust (RAR set, production options, live PAR; damaged set
with lost and corrupt articles) assert no par-check lines, no missing volumes, one par2 load
and nzbget's statuses; liveparraroff is the control with live PAR off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG44gYUGuwLMB2hw7HQGbM
@xbmc4lyfe
xbmc4lyfe force-pushed the live-par-trust-postproc branch from 418981d to 4b3f599 Compare November 27, 2026 01:55
@xbmc4lyfe
xbmc4lyfe marked this pull request as ready for review November 27, 2026 02:05
@xbmc4lyfe
xbmc4lyfe merged commit 4b3f599 into main Nov 27, 2026
0 of 5 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T02:06:01.144638Z 4b3f599 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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