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
This commit is contained in:
parent
9cc1dc69d3
commit
034baa96f6
1 changed files with 28 additions and 12 deletions
|
|
@ -14,23 +14,35 @@
|
||||||
#
|
#
|
||||||
# Busy signal: any of these handlers appearing in Tomcat's stdout log
|
# Busy signal: any of these handlers appearing in Tomcat's stdout log
|
||||||
# within the trailing window means real work is happening right now -
|
# within the trailing window means real work is happening right now -
|
||||||
# video production nodes actively producing, or the timing system
|
# video production nodes actively producing, the live-stream ingest
|
||||||
# actively receiving live race data:
|
# pipeline actively receiving chunks, or the timing system actively
|
||||||
|
# receiving live race data:
|
||||||
# ProductionCommand.get_clipcast_screenplay
|
# ProductionCommand.get_clipcast_screenplay
|
||||||
# ProductionCommand.start_production
|
# ProductionCommand.start_production
|
||||||
# ProductionCommand.update_production
|
# ProductionCommand.update_production
|
||||||
# ProductionCommand.finish_production
|
# ProductionCommand.finish_production
|
||||||
|
# ProductionCommand.append_stream_batch
|
||||||
# ESTPushServlet.null
|
# ESTPushServlet.null
|
||||||
# Deliberately excludes ProductionCommand.peek_productions_queue_new,
|
# Deliberately excludes ProductionCommand.peek_productions_queue_new,
|
||||||
# ProductionCommand.request_batch and ProductionCommand.producer_log -
|
# ProductionCommand.request_batch and ProductionCommand.producer_log -
|
||||||
# those fire continuously from idle nodes kept warm during an event and
|
# those fire continuously from idle nodes kept warm during an event and
|
||||||
# don't indicate real work happening.
|
# don't indicate real work happening.
|
||||||
#
|
#
|
||||||
|
# IMPORTANT: match against the log without anchoring at the start of the
|
||||||
|
# line. Some handlers (append_stream_batch in particular) print an
|
||||||
|
# unterminated progress fragment ("- processed N chunks") immediately
|
||||||
|
# before the request-completion log line with no newline in between, so
|
||||||
|
# the two get glued onto one physical line and "sportrum:" doesn't start
|
||||||
|
# at column 1. An anchored regex missed 99.9% of append_stream_batch's
|
||||||
|
# occurrences in testing (and ~2-4% of the other handlers') - see the
|
||||||
|
# grep -oE approach below, which finds the timestamp+handler substring
|
||||||
|
# anywhere in the line instead.
|
||||||
|
#
|
||||||
# Validated against a real two-day event's log (Cykelvasan, Aug 2026):
|
# Validated against a real two-day event's log (Cykelvasan, Aug 2026):
|
||||||
# these five handlers sit at exactly zero for the entire overnight lull
|
# these six handlers sit at exactly zero for the entire overnight lull
|
||||||
# on both nights, and never dip anywhere near zero during a single
|
# on both nights, and never dip below several hundred matches in any
|
||||||
# minute of live racing - see the excerpt-based tests run alongside this
|
# 10-minute window during live racing - see the excerpt-based tests run
|
||||||
# script's development for the numbers.
|
# alongside this script's development for the numbers.
|
||||||
#
|
#
|
||||||
# Scope: this script only decides *when* to call storeall and calls it.
|
# Scope: this script only decides *when* to call storeall and calls it.
|
||||||
# It does not take the actual pg_dump/webapp backup - that's a separate
|
# It does not take the actual pg_dump/webapp backup - that's a separate
|
||||||
|
|
@ -56,7 +68,7 @@ MAX_RETRIES=24 # ~2 hours of retrying before forcing the run anyway
|
||||||
# old-gen occupancy on the actual server.
|
# old-gen occupancy on the actual server.
|
||||||
HEAP_FORCE_THRESHOLD_PCT=85
|
HEAP_FORCE_THRESHOLD_PCT=85
|
||||||
|
|
||||||
BUSY_PATTERN='ProductionCommand\.(get_clipcast_screenplay|start_production|update_production|finish_production)|ESTPushServlet\.null'
|
BUSY_PATTERN='ProductionCommand\.get_clipcast_screenplay|ProductionCommand\.start_production|ProductionCommand\.update_production|ProductionCommand\.finish_production|ProductionCommand\.append_stream_batch|ESTPushServlet\.null'
|
||||||
|
|
||||||
log() {
|
log() {
|
||||||
echo "$(date '+%Y-%m-%d %H:%M:%S') nightly-storeall: $*"
|
echo "$(date '+%Y-%m-%d %H:%M:%S') nightly-storeall: $*"
|
||||||
|
|
@ -65,16 +77,20 @@ log() {
|
||||||
# Prints the epoch of the most recent busy-pattern line seen in the
|
# Prints the epoch of the most recent busy-pattern line seen in the
|
||||||
# trailing $TAIL_LINES lines of the log. Returns 1 (prints nothing) if
|
# trailing $TAIL_LINES lines of the log. Returns 1 (prints nothing) if
|
||||||
# none found in that tail at all.
|
# none found in that tail at all.
|
||||||
|
#
|
||||||
|
# Uses grep -oE to pull out just the "day mon HH:MM:SS <-> Handler"
|
||||||
|
# substring wherever it occurs on the line, rather than anchoring at the
|
||||||
|
# start of the line - see the note above BUSY_PATTERN for why an anchored
|
||||||
|
# match silently misses most append_stream_batch lines.
|
||||||
last_busy_epoch() {
|
last_busy_epoch() {
|
||||||
local last day mon t
|
local last day mon t
|
||||||
last=$(tail -n "$TAIL_LINES" "$TOMCAT_LOG" \
|
last=$(tail -n "$TAIL_LINES" "$TOMCAT_LOG" \
|
||||||
| grep -E '^sportrum: 6: [0-9]+ [a-z]+ [0-9:]+ <->' \
|
| grep -oE "[0-9]+ [a-z]+ [0-9]{2}:[0-9]{2}:[0-9]{2} <-> (${BUSY_PATTERN})" \
|
||||||
| grep -E "$BUSY_PATTERN" \
|
|
||||||
| tail -n 1)
|
| tail -n 1)
|
||||||
[ -z "$last" ] && return 1
|
[ -z "$last" ] && return 1
|
||||||
day=$(awk '{print $3}' <<< "$last")
|
day=$(awk '{print $1}' <<< "$last")
|
||||||
mon=$(awk '{print $4}' <<< "$last")
|
mon=$(awk '{print $2}' <<< "$last")
|
||||||
t=$(awk '{print $5}' <<< "$last")
|
t=$(awk '{print $3}' <<< "$last")
|
||||||
# NOTE: log lines carry no year, and the month name is locale-dependent
|
# NOTE: log lines carry no year, and the month name is locale-dependent
|
||||||
# (this JVM logs in Swedish locale - "maj"/"okt" would not parse here,
|
# (this JVM logs in Swedish locale - "maj"/"okt" would not parse here,
|
||||||
# though every month actually exercised so far happens to be spelled
|
# though every month actually exercised so far happens to be spelled
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue