fix(warehouse): do NOT create the live-mark matview on store init (crashlooped the cockpit)

ensure_latest_matview() in _create_schema ran on EVERY cockpit pod startup (the store is built at app
startup), and CREATE MATERIALIZED VIEW over the ~4M-row bybit_features hypertable blocked uvicorn from
binding 8080 -> readiness/liveness failed -> crashloop -> cockpit down (and image is :latest so a rollout
undo did not help). The matview is now created/refreshed ONLY by the nightly ingest (refresh_latest);
read_latest falls back to the LATERAL until it exists, so the cockpit boots instantly and is never wrong.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
jgrusewski
2026-06-27 17:04:22 +02:00
parent 6bd2ea61ad
commit 9afa752e47

View File

@@ -92,9 +92,11 @@ class TimescaleFeatureStore:
# Hypertable + compression: best-effort perf layer, guarded so it no-ops without timescaledb.
if self._is_pg:
self._try_make_hypertable()
# Live-mark matview: idempotently create it at setup so the cockpit's read_latest fast path is live as
# soon as the bybit_features store exists (no separate migration step). No-op off-PG/off-bybit.
self.ensure_latest_matview()
# NB: the live-mark matview is NOT created here — CREATE MATERIALIZED VIEW over the ~4M-row hypertable
# is far too heavy for the store-init path, which runs on EVERY cockpit pod startup (it blocked uvicorn
# from binding → readiness/liveness failed → crashloop). The matview is created + refreshed ONLY by the
# nightly ingest (refresh_latest → ensure_latest_matview); read_latest falls back to the LATERAL until
# then, so the cockpit boots instantly and is never wrong.
# -- live-mark matview (PG + bybit_features only; perf layer, never affects correctness) ---------
def ensure_latest_matview(self) -> None: