{"record":{"id":"febc24e3321ca87e","repo":"gastownhall/beads","slug":"failed-to-query-dolt-status-w","errorCode":null,"errorMessage":"failed to query dolt_status: %w","messagePattern":"failed to query dolt_status: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/store.go","lineNumber":3065,"sourceCode":"\t// GH#2455: stage each dirty table individually, skipping config unless the\n\t// mode opts it in, to avoid sweeping up stale issue_prefix changes from\n\t// concurrent operations. Exclude dolt_ignore'd tables (wisps, wisp_%, leases)\n\t// with the same anti-join HasCommittablePending uses: they surface in\n\t// dolt_status but are never stageable, and the fail-hard DOLT_ADD loop below\n\t// must see only tables it can actually stage. A dirty wisp or lease row is the\n\t// normal steady state; staging it depends on Dolt's version-specific\n\t// ignored-table DOLT_ADD behavior (a silent no-op on 2.2.0), so filtering here\n\t// keeps ordinary commits from failing whenever an ignored table is dirty.\n\trows, err := conn.QueryContext(ctx, `\n\t\tSELECT s.table_name FROM dolt_status s\n\t\tWHERE NOT EXISTS (\n\t\t\tSELECT 1 FROM dolt_ignore di\n\t\t\tWHERE di.ignored = 1\n\t\t\tAND s.table_name LIKE di.pattern\n\t\t)`)\n\tif err != nil {\n\t\t// If dolt_status fails, fall back to nothing (rare edge case).\n\t\treturn fmt.Errorf(\"failed to query dolt_status: %w\", err)\n\t}\n\tvar tables []string\n\tconfigDirty := false\n\tfor rows.Next() {\n\t\tvar table string\n\t\tif err := rows.Scan(&table); err != nil {\n\t\t\t_ = rows.Close()\n\t\t\treturn fmt.Errorf(\"failed to scan dolt_status: %w\", err)\n\t\t}\n\t\tif table == \"config\" {\n\t\t\tconfigDirty = true\n\t\t\tif mode == configExclude {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\ttables = append(tables, table)\n\t}\n\t_ = rows.Close()","sourceCodeStart":3047,"sourceCodeEnd":3083,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/store.go#L3047-L3083","documentation":"After pinning a connection, the commit path queries dolt_status to discover dirty tables (excluding dolt_ignore'd tables like wisps and leases). This error wraps a failure of that QueryContext call itself. It means dirty-table discovery failed, so the commit is aborted before anything is staged; per the code comment this is treated as a rare edge case rather than a recoverable fallback.","triggerScenarios":"The SELECT against dolt_status fails: Dolt server error, session/transaction state invalid on the pinned connection, dolt_status table unavailable (very old Dolt version), or transient I/O error during query execution.","commonSituations":"Running against a Dolt version that predates or misbehaves for dolt_status; a killed Dolt process mid-query; corrupted session state after a prior failed stored-procedure call on the same connection.","solutions":["Check the wrapped driver error; retry the operation on a fresh pinned connection if it was transient.","Upgrade the Dolt engine/driver to a current version if dolt_status is unsupported or buggy.","Verify no other session holds conflicting locks on the working set (e.g. an open merge or concurrent DOLT_COMMIT).","Re-run bd sync/commit; the abort happened before staging, so no partial state persists."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// precheck engine support\nvar one int\nif err := conn.QueryContext(ctx, \"SELECT 1 FROM dolt_status LIMIT 1\").Scan(&one); err != nil {\n\t// dolt_status unusable — surface engine/version problem first\n}","typeGuard":null,"tryCatchPattern":"err := store.Commit(ctx, msg)\nif err != nil && strings.Contains(err.Error(), \"failed to query dolt_status\") {\n\t// retry on fresh connection; else report engine issue\n}","preventionTips":["Keep the Dolt engine and Go driver versions current and matched.","Resolve open merges before committing (dolt_merge_status).","Retry transient SQL errors once on a fresh pinned connection.","Avoid killing the Dolt process during sync operations."],"tags":["go","dolt","sql","query"],"backgroundTag":"dolt-status-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}