tracks: hash the carried payload with -f streamhash, never through a PIPE pair
stream_signature() ran ffmpeg -f data - with stdout=PIPE, stderr=PIPE and drained stdout first, reading stderr only after EOF. A source that floods stderr (a Matroska with 1,612 'exceeds containing master element' errors = 219,020 bytes) fills the 64 KB stderr buffer, ffmpeg blocks writing it, stdout never closes and the read loop blocks for ever - 42 min at 2.1 s of CPU, and the supervisor's gate watchdog killed the same item three times at 60 min each. p.wait(timeout=1800) cannot help: it is unreachable until that loop ends. -f streamhash -hash md5 - lets ffmpeg do the md5 itself (byte-identical: 5cb7483040... both ways on that file, 2.3 s instead of a 48.9 MB pipe) and one subprocess.run(capture_output=True, timeout=...) drains both fds on threads, so the stderr flood cannot wedge and a wedged demuxer costs a bounded wait that returns None (the gate then says 'could not hash payload', never 'payload differs'). Return shape (nb_packets, md5) and every caller unchanged. test_tracks 55/55, including 'e2e mkv/mp4: copied streams are byte-identical' on the real fixtures.
This commit is contained in:
1 parent
7c1a243aad
commit
b1b7dbdff1
3 files changed
+73
-16
No files matched your search
@@ -37,6 +37,14 @@ There are **no credentials** in this project, so there is no `SECRETS.md`.
|
||||
6. **Never write encode output straight to a network share.** Encode to local disk, verify,
|
||||
then copy the complete file across; a streaming `.part` write leaves a corrupt stub on any
|
||||
blip. If the destination is remote, keep the output local.
|
||||
7. **Never read one child PIPE while leaving the other undrained.** `subprocess.run(...,
|
||||
capture_output=True, timeout=…)` (or sending the noisy fd to a file) is the default; a
|
||||
`while p.stdout.read():` loop with `p.stderr` still holding a PIPE will deadlock the moment
|
||||
the child fills that pipe — measured 2026-11-15: a corrupt Matroska emitted 219 KB of
|
||||
container errors, ffmpeg blocked writing stderr, the gate sat 42 min at 2.1 s CPU and the
|
||||
supervisor killed the item three times (see `STATE.md` bug 14). `p.wait(timeout=)` does
|
||||
NOT save you: it is unreachable until that read loop ends. A loop that drains a child owes
|
||||
itself a deadline.
|
||||
|
||||
## 3. Layout
|
||||
|
||||
|
||||
Reference in new issue
Block a user