From 68b786416aa69162804e8e25f8cc1b3043622141 Mon Sep 17 00:00:00 2001 From: jedarden Date: Thu, 25 Jun 2026 01:40:24 -0400 Subject: [PATCH] fix(db): add LIMIT to fetchRecentMatchIds query to prevent OOMKill The query in fetchRecentMatchIDs was fetching all completed matches from the last 24 hours without a LIMIT clause. In a high-traffic environment with thousands of matches per day, this would cause the pod to run out of memory and be OOMKilled. This fix adds LIMIT 5000 to cap the number of recent matches fetched, preventing unbounded memory growth while still providing sufficient data for warm asset bundling. Fixes acb-index-builder CrashLoopBackOff (4713 restarts over 45 days). --- cmd/acb-index-builder/main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/acb-index-builder/main.go b/cmd/acb-index-builder/main.go index ff6d0b7..1551315 100644 --- a/cmd/acb-index-builder/main.go +++ b/cmd/acb-index-builder/main.go @@ -356,6 +356,7 @@ func fetchRecentMatchIDs(ctx context.Context, db *sql.DB, since time.Duration) ( WHERE status = 'completed' AND completed_at > NOW() - $1::interval ORDER BY completed_at DESC + LIMIT 5000 ` intervalStr := fmt.Sprintf("%.0f seconds", since.Seconds())