From bbe5f45ac11eaf14c39663d6eb8f0b7134a1dbff Mon Sep 17 00:00:00 2001 From: jedarden Date: Thu, 25 Jun 2026 00:52:50 -0400 Subject: [PATCH] fix(db): add LIMITs to unbounded queries in fetchEvolutionMeta and fetchLineage - Add LIMIT 100 to island populations query (fetchEvolutionMeta) - Add LIMIT 10000 to lineage programs query (fetchLineage) These queries had no row limits, causing OOMKill when the programs table grew large. The pod crashed silently after "Copied web assets" because Go panics and OOMKills exit without logging to slog. Fixes acb-index-builder CrashLoopBackOff (4700+ restarts, 45 days). --- cmd/acb-index-builder/db.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/acb-index-builder/db.go b/cmd/acb-index-builder/db.go index 09563b9..e8ac8c7 100644 --- a/cmd/acb-index-builder/db.go +++ b/cmd/acb-index-builder/db.go @@ -1111,7 +1111,7 @@ func fetchEvolutionMeta(ctx context.Context, db *sql.DB) (*EvolutionMeta, error) // Fetch island populations meta.IslandPopulations = make(map[string]int) islandRows, err := db.QueryContext(ctx, ` - SELECT island, COUNT(*) FROM programs GROUP BY island + SELECT island, COUNT(*) FROM programs GROUP BY island LIMIT 100 `) if err == nil { for islandRows.Next() { @@ -1182,6 +1182,7 @@ func fetchLineage(ctx context.Context, db *sql.DB) ([]LineageNode, error) { SELECT id, parent_ids, generation, island, fitness, promoted, language, created_at FROM programs ORDER BY generation ASC, id ASC + LIMIT 10000 ` rows, err := db.QueryContext(ctx, query)