multica-ai/multica · error
iterate dry-run summary: %w
Error message
iterate dry-run summary: %w
What it means
Returned when rows.Err() is non-nil after iterating the dry-run summary — i.e. the iteration itself failed mid-cursor (network drop, statement timeout, context cancellation via SIGINT) rather than the initial query or a single row scan. Partial summaries may already be logged; no data was modified because this is read-only phase.
Source
Thrown at server/cmd/backfill_codex_usage_cache/main.go:231
&row.Rows,
&row.InputBefore,
&row.InputAfter,
&row.Overcount,
&row.ClampedRows,
&row.MinCreatedUTC,
&row.MaxCreatedUTC,
); err != nil {
return nil, totals{}, fmt.Errorf("scan dry-run summary: %w", err)
}
summaries = append(summaries, row)
total.Rows += row.Rows
total.InputBefore += row.InputBefore
total.InputAfter += row.InputAfter
total.Overcount += row.Overcount
total.ClampedRows += row.ClampedRows
}
if err := rows.Err(); err != nil {
return nil, totals{}, fmt.Errorf("iterate dry-run summary: %w", err)
}
return summaries, total, nil
}
func logSummary(cfg config, rows []summaryRow, total totals) {
slog.Info("Codex usage cache backfill candidate total",
"execute", cfg.execute,
"cutoff", cfg.cutoff.Format(time.RFC3339),
"workspace_id", cfg.workspaceID,
"rows", total.Rows,
"input_before", total.InputBefore,
"input_after", total.InputAfter,
"input_tokens_removed", total.Overcount,
"clamped_rows", total.ClampedRows)
for _, row := range rows {
slog.Info("candidate summary",
"workspace_id", row.WorkspaceID,
"date_utc", row.DateUTC,View on GitHub (pinned to 2c0912b6ec)
Solutions
- If a statement timeout is named in the wrapped error, raise it for the session (e.g. options='-c statement_timeout=0' in the DSN) and re-run.
- Scope the dry-run with --workspace-id to shrink the cursor, then run per workspace.
- If you Ctrl-C'd it, simply re-run; the phase is read-only and safe to repeat.
Example fix
# before DATABASE_URL='postgres://...?sslmode=require' ./backfill_codex_usage_cache --cutoff ... # iterate dry-run summary: ... statement timeout # after DATABASE_URL='postgres://...?sslmode=require&options=-c%3Dstatement_timeout%3D0' \ ./backfill_codex_usage_cache --cutoff 2026-06-01T12:00:00Z
Defensive patterns
Strategy: retry
Validate before calling
# Raise statement timeout for the session when summarizing huge tables
export DATABASE_URL="${DATABASE_URL}?options=-c%3Dstatement_timeout%3D0" Prevention
- Scope dry-runs per workspace (--workspace-id) on very large datasets.
- Avoid Ctrl-C during summary iteration; it is read-only and finishes faster than it appears to hang.
- Keep the connection stable (watch pgbouncer idle timeouts) for the full run.
When it happens
Trigger: Statement timeout or connection loss while streaming a large summary cursor; Ctrl-C (signal.NotifyContext cancels ctx) during iteration; postgres restart mid-cursor.
Common situations: Very large task_usage tables exceeding statement_timeout on the summary query; flaky network to a remote database; operators aborting what looks like a hang.
Related errors
- update Codex task_usage batch: %w
- connect to database: %w
- ping database: %w
- acquire advisory-lock connection: %w
- acquire advisory lock %d: %w
AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15).
Data as JSON: /api/errors/60bcba941efc2a72.
Report an issue: GitHub.