From be9a070fbb615026129edec55603398715692174 Mon Sep 17 00:00:00 2001 From: jedarden Date: Thu, 25 Jun 2026 06:29:12 -0400 Subject: [PATCH] fix(db): add LIMIT to bot match stats query to prevent OOMKill The bot match stats query was introduced in b35a2aa to fix an N+1 query problem, but it was unbounded and could return an unlimited number of rows. With many bots in the database, this query could consume excessive memory and cause OOMKill, resulting in silent crashes after 'Copied web assets'. Add LIMIT 20000 to prevent unbounded result sets while supporting large bot populations (the main bots query already limits to 10000 bots). This fix continues the pattern of adding LIMITs to prevent OOMKill crashes in acb-index-builder. Fixes bead bf-2ws: acb-index-builder CrashLoopBackOff investigation --- cmd/acb-index-builder/db.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/acb-index-builder/db.go b/cmd/acb-index-builder/db.go index 789dc81..20312ba 100644 --- a/cmd/acb-index-builder/db.go +++ b/cmd/acb-index-builder/db.go @@ -346,6 +346,7 @@ func fetchBots(ctx context.Context, db *sql.DB) ([]BotData, error) { JOIN matches m ON mp.match_id = m.match_id WHERE m.status = 'completed' GROUP BY mp.bot_id + LIMIT 20000 `) if err != nil { return nil, fmt.Errorf("query bot match stats: %w", err)