{"record":{"id":"eaf6fa2013cdac21","repo":"multica-ai/multica","slug":"ping-database-w","errorCode":null,"errorMessage":"ping database: %w","messagePattern":"ping database: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"server/cmd/backfill_codex_usage_cache/main.go","lineNumber":96,"sourceCode":"\t\treturn err\n\t}\n\n\tdbURL := os.Getenv(\"DATABASE_URL\")\n\tif dbURL == \"\" {\n\t\tdbURL = \"postgres://multica:multica@localhost:5432/multica?sslmode=disable\"\n\t}\n\n\tctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)\n\tdefer stop()\n\n\tpool, err := pgxpool.New(ctx, dbURL)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"connect to database: %w\", err)\n\t}\n\tdefer pool.Close()\n\n\tif err := pool.Ping(ctx); err != nil {\n\t\treturn fmt.Errorf(\"ping database: %w\", err)\n\t}\n\n\trows, total, err := loadDryRunSummary(ctx, pool, cfg)\n\tif err != nil {\n\t\treturn err\n\t}\n\tlogSummary(cfg, rows, total)\n\tif total.Rows == 0 {\n\t\tslog.Info(\"no eligible Codex task_usage rows found\")\n\t\treturn nil\n\t}\n\tif !cfg.execute {\n\t\tslog.Info(\"dry-run complete; review the summary, then re-run with --execute to apply the backfill\")\n\t\treturn nil\n\t}\n\n\tlockConn, err := pool.Acquire(ctx)\n\tif err != nil {","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/backfill_codex_usage_cache/main.go#L78-L114","documentation":"Returned when the pool was created but pool.Ping(ctx) fails — the tool's first actual round-trip to postgres. It means the DSN parsed and the pool object exists, but the server rejected or never answered the connection: wrong credentials, database does not exist, pg_hba rejection, TLS failure, or network drop. Distinguish it from 'connect to database', which is a DSN/pool-construction failure.","triggerScenarios":"Valid-format DSN with wrong password/user (auth failure), non-existent database name, pg_hba.conf denying the client IP, server requiring TLS the client didn't negotiate, or a firewall dropping the connection after DNS resolution.","commonSituations":"Credentials rotated after the DSN was written; pointing at the right host but the wrong database name; running the backfill from CI/NAT whose IP is not in pg_hba; managed postgres enforcing SSL while sslmode=disable.","solutions":["Confirm credentials and database name in DATABASE_URL by connecting with psql using the same DSN.","Match sslmode to the server (try sslmode=require for managed postgres).","If pg_hba rejects the client, run the tool from an allowed host or have the DBA allow it.","Re-run — transient network blips between pool creation and ping are possible."],"exampleFix":"# before\nexport DATABASE_URL='postgres://multica:multica@localhost:5432/multica?sslmode=disable'\n./backfill_codex_usage_cache --cutoff ...  # ping database: ... (auth failed / no ssl)\n\n# after\nexport DATABASE_URL='postgres://multica:multica@db.internal:5432/multica?sslmode=require'\n./backfill_codex_usage_cache --cutoff 2026-01-01T00:00:00Z","handlingStrategy":"retry","validationCode":"# Pre-flight the exact DSN, including TLS mode\nPGCONNECT_TIMEOUT=5 psql \"$DATABASE_URL\" -c 'select 1' || echo 'fix DSN: credentials, dbname, or sslmode'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Match sslmode to the server policy (require for most managed postgres).","Rotate DSNs together with database credentials so they never go stale.","Treat auth failures as configuration bugs — retrying will not help until the DSN is fixed."],"tags":["database","postgres","connectivity","authentication","backfill"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}