mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-05 10:48:18 +01:00
#275 gave "builder online" an expiry, then handed it timestamps that could be minutes old. /api/control's slow cache has a 20s TTL but SERVES STALE while it refreshes in the background, so the first request after an idle spell gets a cache built long before "now". Measured against the real clock, a live runner's heartbeat had already aged past RUNNER_OFFLINE_THRESHOLD_MS — and Control reported a builder that was heartbeating fine as offline. Caught on prod: two probes 12s apart returned runnerVersion "dev" then "box-0.8.9" from the same cache field, proving the cache was serving data built minutes earlier; builderPresence read {cloud:false, local:false} while the DB had connected=t/t/t with snapshots 2.5min and 3.6min old. The fix is to delete the optimisation, not to tune it. getBuilderPresence now does both reads itself, at request time, and no longer accepts caller-supplied heartbeats — an age is only meaningful against the clock it is compared to. Two indexed reads on two-row tables are cheaper than a false liveness claim. Pinned by a regression check so the pass-through cannot come back as a performance tweak. Co-authored-by: t <t@t.t> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>