{"record":{"id":"df9eb67bf7b3f8f1","repo":"gastownhall/beads","slug":"dolt-add-s-after-sql-mutation-w-w","errorCode":null,"errorMessage":"dolt add %s after SQL mutation: %w: %w","messagePattern":"dolt add (.+?) after SQL mutation: %w: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/storage/dolt/store.go","lineNumber":3298,"sourceCode":"func (s *DoltStore) doltAddAndCommit(ctx context.Context, tables []string, commitMsg string) error {\n\t// Batch/off auto-commit (bd-4wamg): leave the writes in the working set\n\t// for a later explicit commit point (bd dolt commit / CommitPending),\n\t// matching doltAddAndCommitInTx.\n\tif issueops.VersionCommitDeferred(ctx) {\n\t\treturn nil\n\t}\n\treturn s.withCircuitWrite(ctx, func(ctx context.Context) error {\n\t\tconn, err := s.db.Conn(ctx)\n\t\tif err != nil {\n\t\t\treturn s.recordDoltPublicationFailure(ctx,\n\t\t\t\tfmt.Errorf(\"acquire connection after SQL mutation: %w: %w\", err, ErrCommitIndeterminate))\n\t\t}\n\t\tdefer conn.Close()\n\n\t\tfor _, table := range tables {\n\t\t\tif err := schema.DrainCall(ctx, conn, \"CALL DOLT_ADD(?)\", table); err != nil {\n\t\t\t\treturn s.recordDoltPublicationFailure(ctx,\n\t\t\t\t\tfmt.Errorf(\"dolt add %s after SQL mutation: %w: %w\", table, err, ErrCommitIndeterminate))\n\t\t\t}\n\t\t}\n\n\t\t// Skip the commit when nothing was actually staged (idempotent no-op\n\t\t// write), so Dolt does not log a server-side \"nothing to commit\" warning\n\t\t// on every reconcile-cadence call. The guard tests the STAGED set rather\n\t\t// than the whole working set because this helper stages only a fixed\n\t\t// table list — an unrelated dirty table must not trigger an empty '-m'\n\t\t// commit. A guard-read failure is NOT a publication failure: nothing has\n\t\t// been committed and nothing is indeterminate, so plain error return.\n\t\tstaged, err := issueops.HasStagedChanges(ctx, conn)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"check staged changes before commit: %w\", err)\n\t\t}\n\t\tif !staged {\n\t\t\treturn nil\n\t\t}\n","sourceCodeStart":3280,"sourceCodeEnd":3316,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/store.go#L3280-L3316","documentation":"CALL DOLT_ADD failed for a table after a SQL mutation. Wrapped with ErrCommitIndeterminate because the data mutation succeeded but staging/publication did not, leaving the commit outcome ambiguous.","triggerScenarios":"commitWorkingSetAfterSQLCommit iterates the table list and DOLT_ADD fails — server unreachable, table locked, or the table name is not a valid Dolt table after a rename/schema change.","commonSituations":"Dolt server restart mid-operation; schema drift after a bd version upgrade left a listed table missing; lock contention with another writer.","solutions":["Check `bd dolt status` to see whether some/all tables were staged and whether the commit landed; do not blind-retry an indeterminate write.","Restore server connectivity and re-run; staging is idempotent.","If the table is missing, verify schema version consistency between bd and the database (bd doctor).","Check for locks from other bd processes and wait/retry."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// confirm all target tables exist before the mutation/commit sequence\nfor _, t := range tables {\n    if !tableExists(ctx, conn, t) {\n        return fmt.Errorf(\"table %s missing; run `bd doctor`\", t)\n    }\n}","typeGuard":null,"tryCatchPattern":"if errors.Is(err, ErrCommitIndeterminate) && strings.Contains(err.Error(), \"dolt add\") {\n    // inspect dolt status for staged tables, then resume publication\n}","preventionTips":["Keep bd and the database schema version in sync (run bd doctor after upgrades).","Check `bd dolt status` after any publication failure before retrying.","Avoid concurrent writers on the same tables during mutations.","Monitor server stability during sync windows."],"tags":["dolt","dolt-add","indeterminate-commit","staging"],"backgroundTag":"commit-indeterminate","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}