Engineering · · 2 min read
437 GB Gone Overnight: Two Guards for Batch Rendering
Rendering the 114 chapters of the Quran filled a 437 GB disk; rendering the 1,189 chapters of the Bible, three chapters failed silently while the script still printed "done". Two incidents, two rules for batch jobs.
My recitation videos are rendered character by character: every highlight frame is drawn as a PNG, then ffmpeg stitches them into a video. For one chapter you never notice. For a whole book in a batch, you do.
Incident one: the disk fills up
For the Quran (Ma Jian's Chinese translation, 114 chapters, over 21 hours of audio) I wrote a batch script that ran each chapter in turn: transcribe, align, render, composite.
The problem was the render step: each chapter's folder of frame PNGs was never deleted after compositing. Chapter 2, at 101 minutes, took 21 GB in frames alone. By chapter 24 the 437 GB data partition was full.
After that, transcription and rendering failed for chapter after chapter. At least it was a loud failure — obvious at a glance.
The fix was simple:
- After each chapter — whether it succeeded or failed — delete its frame folder and intermediate transcription files.
- Before each chapter, check free disk space and stop automatically below 5 GB instead of writing into a full disk.
Incident two: silent failure
The next one was harder to spot. While rendering the Chinese Union Bible (66 books, 1,189 chapters), the disk ran short again for a while and ffmpeg failed while compositing.
But the batch script at the time didn't check exit codes. If transcription, alignment, rendering or compositing failed, it carried on and printed "done" at the end. Three chapters' videos simply didn't exist, and nobody noticed for hours.
The fix has two layers:
- Check every step's exit code and stop on that chapter if it fails. No pretending.
- A separate audit script that walks the final outputs in chapter order and finds the gaps.
One detail in the audit is worth writing down. The first rule was: "if a chapter is missing but any later chapter exists, the batch has passed it, so this chapter was dropped." It immediately reported 122 false gaps.
Before the real batch I had tested a few chapters by hand, out of order, and those videos sat there on their own. One isolated test output further along was enough to mark every not-yet-processed chapter before it as "missing".
The rule became: a chapter is a gap only if it is followed immediately by a run of at least five chapters that do exist. A single isolated chapter doesn't prove the batch got that far; a consecutive run does. After the change, it reported exactly those three chapters.
Rules from now on
- Every intermediate output of a batch job gets an explicit clean-up point — on the failure path too.
- Long jobs check remaining resources (disk, memory) before each unit and stop when short.
- Check every step's exit code; "error, but print done anyway" is not allowed.
- "Done" means the final output really exists, verified by an independent audit script, not by the log.
- Detect gaps with consecutive evidence, so stray manual test outputs can't mislead you.