fix(collect): no stack overflow on huge statements; every failure closes the run as FAILED #12

Merged
KofTwentyTwo merged 1 commits from fix/collector-failures into develop 2026-10-15 22:43:05 +00:00
KofTwentyTwo commented 2026-10-15 22:40:12 +00:00 (Migrated from github.com)

Prod kof22 snapshots stayed RUNNING with nothing logged. Cause: SqlNormalizer folded IN/VALUES lists with nested-repetition regexes, which throw StackOverflowError on very long lists (kof22 has 16 statements over 10 KB, max 63 KB). The Error escaped catch(Exception), so the run row stayed RUNNING, no log, no alert. pg_stat_statements on prod confirms the collector read pg_stat_statements and never reached the first insert.

  • Linear token scan for list folding (same output, tested with 20,000-element lists).
  • Collector catches Throwable (rethrows OOM), logs ERROR with exception class + throwing frame (never SQL text), marks FAILED, alert fires via SnapshotEvaluator.
  • Stale RUNNING runs (older than 3 intervals) are closed as FAILED ("did not finish").
  • Verified locally against kof22's 4,462 real normalized statement texts: all normalize/fingerprint/parse in under 1 s total (the old code overflowed).

Tests: 104 pass (new: errorsAndAbandonedRuns, huge-list normalizer cases).

🤖 Generated with Claude Code

Prod kof22 snapshots stayed RUNNING with nothing logged. Cause: `SqlNormalizer` folded IN/VALUES lists with nested-repetition regexes, which throw `StackOverflowError` on very long lists (kof22 has 16 statements over 10 KB, max 63 KB). The Error escaped `catch(Exception)`, so the run row stayed RUNNING, no log, no alert. pg_stat_statements on prod confirms the collector read pg_stat_statements and never reached the first insert. - Linear token scan for list folding (same output, tested with 20,000-element lists). - Collector catches `Throwable` (rethrows OOM), logs ERROR with exception class + throwing frame (never SQL text), marks FAILED, alert fires via SnapshotEvaluator. - Stale RUNNING runs (older than 3 intervals) are closed as FAILED ("did not finish"). - Verified locally against kof22's 4,462 real normalized statement texts: all normalize/fingerprint/parse in under 1 s total (the old code overflowed). Tests: 104 pass (new: errorsAndAbandonedRuns, huge-list normalizer cases). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.