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
This commit is contained in:
parent
b35a2aade0
commit
be9a070fbb
1 changed files with 1 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue