Repository navigation
Description
Summary
pkgs/cold-store-reaper/scripts/repair_dump.py — the streaming repair filter between the libsql /dump download and the sqlite3 rebuild in scripts/export-turso.sh — is documented as constant-memory, but a candidate INSERT INTO sqlite_schema( statement whose terminating line never arrives is buffered in full, without any bound, so the filter's memory grows to the size of the remaining dump and nothing is emitted until EOF.
Evidence (file:line, origin/main 6b9e1ec081ac)
- The promise:
repair_dump.py:22-25— "The filter is line-oriented and constant-memory: it buffers only the lines of one candidate statement (which ends at a line ending in');)";export-turso.sh:187-191repeats it: "streams the dump (constant memory, one statement buffered)". - The code:
repair_dump.py:142-161(main). Once a line starts withINSERT INTO sqlite_schema(and does not end in');, every later line is appended tobuffered(:146-151) until a line ending in');appears; there is no size cap, no spill, and no flush-through. The accumulated list is only joined and emitted at the terminator (:149) or at EOF (:159-160).
Verification (laptop probe, this run)
Probe ~/git/fleet/probe-repair-dump/ (driver2.py) against the real script exported from origin/main 6b9e1ec081ac, stdin held open while measuring stdout and RSS:
- Control — 32 MiB of ordinary lines: streamed through; 33,488,896 B already on stdout before EOF; RSS 13,148 KiB.
- Unterminated candidate — the same 32 MiB after one
INSERT INTO sqlite_schema(... 'CREATE TABLE t (line with no');line: 0 B on stdout before EOF; RSS 47,604 KiB (≈ the full 32 MiB input held in memory, +34 MB over the control). Output after EOF is byte-identical (33,554,534 B, rc 0) — the failure is memory, not correctness. - Functional controls on the real script: a verifiably mis-escaped FTS5 schema literal is repaired (quotes doubled), and an unterminated statement at EOF flushes unchanged — both pass, matching the existing
TestDumpRepairFilterexpectations.
Why it matters
The filter sits in the Turso export path (export-turso.sh:191) precisely so large dumps can be processed without holding them in memory — the same package's recent #6233 work bounded memory when Drive ignores Range requests. A dump whose schema statement is cut or re-shaped so its terminator line never matches (truncated/corrupt download, a libsql format change such as trailing whitespace after ');, or a genuinely huge multi-line schema statement) turns the "constant-memory" filter into a whole-dump buffer: on the backup host that is an avoidable OOM risk in the one job whose job is keeping backups restorable, and it fails silently — output stays byte-correct, just unbounded. This is the same shape as the fleet-proxy single-line head bound filed as #6511 (check exists, but only after the unbounded accumulation).
Acceptance criteria
- A candidate statement that exceeds a stated, generous bound (well above any real schema statement) is no longer accumulated without limit: e.g. flush the buffered lines through unchanged and resume line-oriented passthrough, or another design that keeps peak memory independent of the remaining dump size.
- Byte-identical output is preserved in every currently-correct case: mis-escaped literals still repaired, valid literals untouched, unterminated-at-EOF still flushed unchanged (existing
TestDumpRepairFilterintests/test_export_turso.pypasses unchanged). - A new regression test in
TestDumpRepairFilterpins the bound: an unterminated candidate larger than the bound produces output before EOF / bounded memory, with the full stream still byte-identical end-to-end. - The docstring and the
export-turso.shcomment match the implemented bound (name the cap).
Filed by the new-issue-creator (lane A) after verification this run; not a duplicate of #1391 (the original mis-escaping quirk this filter works around) — this is the filter's own memory contract.
Activity
developing-today commentedon Nov 6, 2026
CODE-1980
dezren39 commentedon Nov 6, 2026
🤖 Agent note · filed
INSERT INTO sqlite_schema(candidate line produces 0 B before EOF at RSS 47,604 KiB — the whole remainder is buffered, contradicting the filter's documented constant-memory contract (repair_dump.py:22-25; main loop :142-161 has no bound). Functional controls pass: mis-escaped FTS5 literal repaired, unterminated-at-EOF flushes byte-identical. Dedup: no open or closed filing for repair_dump's buffering; Upstream quirk: libsql /dump does not escape single quotes in sqlite_schema INSERTs for virtual tables (FTS5) — cold-store reaper works around it #1391 is the original mis-escaping quirk, not this.dezren39 commentedon Nov 6, 2026
🤖 Agent note · picked up
181 remaining items
fix(cold-store-reaper): recognise pass-through statement end from its…
fix(cold-store-reaper): pass-through boundary from tracker/lookahead …
Merge pull request #8415 from developing-today/queue/14417-6525-repai…
dezren39 commentedon Nov 11, 2026
Agent note — lane tmp-code-t, task 14417 — DONE fixed_merged