Commit graph

5 commits

Author SHA1 Message Date
Claude
2478310f55
Split heap-pressure escape hatch out of nightly-storeall.sh
nightly-storeall.sh and the heap-pressure safety valve have genuinely
different schedules: the former should run once a night and is patient
(wait for quiet traffic, bounded retry), the latter needs to run every
10-15 minutes around the clock and is impatient (heap occupancy only
climbs while storeall is deferred, so it forces a run immediately with
no regard for traffic once critical). Cramming both into one script
meant they could only ever run on the same cadence.

nightly-storeall.sh: dropped heap_pressure_critical and
HEAP_FORCE_THRESHOLD_PCT entirely - it's now traffic-driven only.

emergency-storeall.sh: new script, just the heap check + immediate
storeall if critical, exits 0 doing nothing otherwise so it's cheap to
run on a tight cron schedule.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 11:46:00 +00:00
Claude
034baa96f6
Fix busy-check to not anchor on start-of-line, add append_stream_batch
Two fixes surfaced while adding append_stream_batch (live-stream chunk
ingest) as a sixth busy indicator, per a walkthrough of the log:

1. The request-completion log line doesn't always start at column 1.
   Some handlers print an unterminated progress fragment right before it
   with no newline in between ("- processed N chunkssportrum: 6: ..."),
   so an anchored ^sportrum: regex missed 99.9% of append_stream_batch's
   occurrences in testing, and ~2-4% of the original five handlers' too
   (not enough to break their validation, but still wrong). Switched to
   grep -oE pulling the timestamp+handler substring from anywhere on the
   line instead of anchoring at the start.

2. Added ProductionCommand.append_stream_batch to BUSY_PATTERN - it's
   the live camera/stream ingest pipeline, active independently of both
   video production and race timing. Notably starts earlier than
   anything else tracked: on the event's setup day, a full day before
   the race itself.

Re-validated against real log excerpts with both fixes in place: nights
still read as exactly zero, and both a mid-stream-test-burst case and a
well-after-the-burst case resolve correctly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 11:38:22 +00:00
Claude
9cc1dc69d3
Add nightly-storeall.sh: wait-for-idle gate before triggering storeall
Adds the script that decides when it's safe to flush in-memory state via
the app's storeall command, so a nightly backup's freeze doesn't land on
top of live race/production traffic.

Busy signal is presence, within a trailing window, of any of five Tomcat
stdout log handlers (get_clipcast_screenplay/start_production/
update_production/finish_production/ESTPushServlet) - deliberately
excludes the idle-node polling handlers (peek_productions_queue_new,
request_batch, producer_log), which fire continuously regardless of
whether real work is happening. Validated the exact bash logic (not just
the concept) against excerpts of a real two-day event's production log:
zero false positives/negatives across quiet-night, pre-event, ramp-up,
and peak-racing cases at a 10-minute window.

Two escape hatches force the run regardless of traffic: a bounded retry
budget (default ~2h) and a JVM old-gen heap-pressure check via
supervisorctl+jstat, since storeall is the only thing that flushes state
to Postgres and the only thing that unblocks the registry's WeakHashMap
GC eviction for anything currently dirty - it can't be deferred forever.

Two things are still placeholders, not yet validated against the real
server: TOMCAT_LOG's actual path (depends on supervisord's
stdout_logfile setting) and HEAP_FORCE_THRESHOLD_PCT (needs a real jstat
baseline). Both are called out inline.

Scope is deliberately narrow: this script only decides when to call
storeall and calls it. Taking the actual pg_dump/webapp backup is a
separate step to chain after a successful run.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 11:29:45 +00:00
Claude
b0c2893ad7
Parameterize runcmd to support commands beyond storeall
runcmd was hardcoded to the storeall command/status-file pair. Generalizing
it now so finishcalls and dumpregistry (planned server-side additions) can
reuse the same commands.txt/status.<cmd>.$pid polling handshake instead of
needing near-duplicate copies of the function.

Signature changed from `runcmd <resultvar>` to `runcmd <resultvar> <command>
[args...]`; updated the two existing call sites (restart.sh, upgrade.sh)
accordingly. Behavior for storeall itself is unchanged - verified the
generated commands.txt line is byte-identical to before.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-29 20:51:47 +00:00
Claude
54bfeb73e7
Import existing manual deploy scripts as a starting point
These are the scripts currently run by hand on the old EC2 server to do a
full upgrade (safe storeall handshake, backups, explode WAR, run the
manager schema-migration tool, restart Tomcat). Committed as-is for now to
review and refactor from, except tomcat_ctl.sh, which is already rewritten
to control Tomcat via the new Docker container's supervisord (through the
"service" shim) instead of the old host's /etc/init.d/tomcat8, since that
service doesn't exist there. Kept as a drop-in replacement: the "status"
output still contains both literal substrings upgrade.sh and restart.sh
each grep for, so neither caller needed to change yet.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-29 17:04:18 +00:00