Each upgrade already writes a SQL dump + webapp/WAR snapshot pair
under a shared timestamp for tactical rollback. Add automatic
pruning of pairs older than RETENTION_DAYS (14), run right after
manager-exec.sh upgrade succeeds so nothing is discarded if the
upgrade itself failed. Pruning works from the union of timestamps
across sql/webapp/logs so a partial pair (one artifact skipped via
-f/-w) is still cleaned up without erroring.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
Check interval now adapts to the last observed condition instead of a
fixed cron cadence: every 30 min while normal, every 10 once elevated
or critical, so cron only needs one entry at the fastest interval this
ever needs. Also bundles recent request count/rate/avg duration from
Tomcat's stdout log into the same check and MaintenanceLog entry, to
give the heap numbers traffic context rather than running as a
separate job.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
Follows nightly-storeall.sh's cron-driven, single-check-per-invocation
shape and logs via maintenance_log(). No longer forces storeall - that
stays a manual decision until real incident data is available to
calibrate a trigger. Every run logs old-gen occupancy plus Full/Young
GC numbers and a normal/elevated/critical condition label, building a
GC history dataset for whenever that calibration work resumes.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
nightly-storeall.sh no longer sleeps/retries internally - it's meant to
be invoked every 30 min from 21:00-06:00 by cron and does a single
check-and-maybe-act per run, so a missed/killed run just gets picked up
at the next tick instead of losing all progress. No forced fallback if
still busy at the 06:00 cutoff - that's handled manually for now.
Add maintenance_log() to upgrade-funs.sh: drops a MaintenanceLog XML file
per event into WEB-INF/storage/maintenance-log/ (atomic temp+rename) for
the webapp to pick up and route to sms/email/etc via its own machinery.
Fire-and-forget, matching the shape of MaintenanceLog.java.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
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
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
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
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
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