Past Issues Searched
Searched for TrackerScriptCache / tracker_script_cache / readiness; nothing matching.
Version
Community Edition v3.2.1 (also checked master: same code in lib/plausible/cache.ex and system_controller.ex).
What happened
A single transient DB error during boot makes /api/health (readiness) return 500 for 3 hours, while the app otherwise serves traffic fine. Under Kubernetes with the documented health probe this becomes an infinite restart loop.
Sequence, from logs:
- At boot
Plausible.Cache.Warmer runs refresh_all for every cache at once, plus Oban starts. With a 10-connection pool and a DB a few hundred ms away, the pool hit DBConnection.ConnectionError ... queue_timeout after ~6s.
Plausible.Cache.refresh/3 catches that and only logs Error refreshing 'tracker_script_cache' - ... (cache.ex ~L233). The cache stays empty.
TrackerScriptCache is in @critical_caches for readiness. ready?/1 returns false because size() == 0 but count_all() == 9. Readiness responds 500 {"sessions":"ok","postgres":"ok","clickhouse":"ok","sites_cache":null}.
- The next
refresh_all for tracker_script_cache is scheduled ~3 hours out (interval 10805730 in the warmer init log). refresh_updated_recently runs every 30s but only picks up rows updated since the last run, so it never repairs a cache that missed the initial load.
- If the deployment's startup/liveness probe points at
/api/health, the pod is killed long before 3h elapse, and the cycle repeats on every boot. I saw 56 consecutive restarts.
Plausible.Site.Cache and Plausible.Shield.IPRuleCache have the same shape but shorter refresh_all intervals (15 min / 3 min), so they self-heal before anyone notices.
Expected
A failed boot-time refresh_all should retry (short backoff) instead of waiting for the next multi-hour cycle, or refresh_updated_recently should fall back to a full refresh while ready?/1 is false.
Workaround
bin/plausible rpc 'Plausible.Site.TrackerScriptCache.refresh_all()' inside the container makes readiness green immediately. For Kubernetes, point startup/liveness at /api/system/health/live and keep /api/health for readiness only.
Past Issues Searched
Searched for TrackerScriptCache / tracker_script_cache / readiness; nothing matching.
Version
Community Edition v3.2.1 (also checked
master: same code inlib/plausible/cache.exandsystem_controller.ex).What happened
A single transient DB error during boot makes
/api/health(readiness) return 500 for 3 hours, while the app otherwise serves traffic fine. Under Kubernetes with the documented health probe this becomes an infinite restart loop.Sequence, from logs:
Plausible.Cache.Warmerrunsrefresh_allfor every cache at once, plus Oban starts. With a 10-connection pool and a DB a few hundred ms away, the pool hitDBConnection.ConnectionError ... queue_timeoutafter ~6s.Plausible.Cache.refresh/3catches that and only logsError refreshing 'tracker_script_cache' - ...(cache.ex ~L233). The cache stays empty.TrackerScriptCacheis in@critical_cachesfor readiness.ready?/1returnsfalsebecausesize() == 0butcount_all() == 9. Readiness responds500 {"sessions":"ok","postgres":"ok","clickhouse":"ok","sites_cache":null}.refresh_allfortracker_script_cacheis scheduled ~3 hours out (interval 10805730in the warmer init log).refresh_updated_recentlyruns every 30s but only picks up rows updated since the last run, so it never repairs a cache that missed the initial load./api/health, the pod is killed long before 3h elapse, and the cycle repeats on every boot. I saw 56 consecutive restarts.Plausible.Site.CacheandPlausible.Shield.IPRuleCachehave the same shape but shorterrefresh_allintervals (15 min / 3 min), so they self-heal before anyone notices.Expected
A failed boot-time
refresh_allshould retry (short backoff) instead of waiting for the next multi-hour cycle, orrefresh_updated_recentlyshould fall back to a full refresh whileready?/1is false.Workaround
bin/plausible rpc 'Plausible.Site.TrackerScriptCache.refresh_all()'inside the container makes readiness green immediately. For Kubernetes, point startup/liveness at/api/system/health/liveand keep/api/healthfor readiness only.