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).
This commit is contained in:
jedarden 2026-06-25 01:40:24 -04:00
parent 7befe516bf
commit 68b786416a

View file

@ -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())