{"record":{"id":"ba32cce38eb07e21","repo":"gastownhall/beads","slug":"clear-s-conflict-w","errorCode":null,"errorMessage":"clear %s conflict: %w","messagePattern":"clear (.+?) conflict: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/versioncontrolops/automerge.go","lineNumber":716,"sourceCode":"\tif _, ok := unionConflictKeyColumns[table]; !ok {\n\t\treturn fmt.Errorf(\"table %s is not union-mergeable\", table)\n\t}\n\tfor _, row := range plan {\n\t\tpreds := make([]string, 0, len(row.columns))\n\t\targs := make([]any, 0, len(row.columns))\n\t\tfor i, k := range row.columns {\n\t\t\tv := row.values[i]\n\t\t\tif v == nil {\n\t\t\t\treturn fmt.Errorf(\"unexpected %s conflict row with no our_%s (safety check bypassed)\", table, k)\n\t\t\t}\n\t\t\tpreds = append(preds, \"`our_\"+k+\"` = ?\")\n\t\t\targs = append(args, v)\n\t\t}\n\t\t//nolint:gosec // table and key columns come from the unionConflictKeyColumns allowlist.\n\t\tstmt := \"DELETE FROM `dolt_conflicts_\" + table + \"` WHERE \" + strings.Join(preds, \" AND \")\n\t\tres, err := db.ExecContext(ctx, stmt, args...)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"clear %s conflict: %w\", table, err)\n\t\t}\n\t\tif n, err := res.RowsAffected(); err == nil && n == 0 {\n\t\t\treturn fmt.Errorf(\"a %s conflict was not cleared (no conflict row deleted)\", table)\n\t\t}\n\t}\n\treturn nil\n}\n","sourceCodeStart":698,"sourceCodeEnd":724,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/versioncontrolops/automerge.go#L698-L724","documentation":"The DELETE issued against dolt_conflicts_<table> failed at the database level; the underlying driver error is wrapped with this message. This means SQL execution itself failed — connection loss, lock contention, a missing or renamed conflict table, or a schema mismatch — not that zero rows matched.","triggerScenarios":"db.ExecContext returns an error while running DELETE FROM `dolt_conflicts_<table>` WHERE our_<keycol> = ? — e.g. the database connection dropped mid-resolution, the conflict table doesn't exist (conflicts already cleared or never created), or a lock/timeout on the table.","commonSituations":"Another process resolved or cleared conflicts concurrently and dropped the conflict table; the dolt server restarted or the connection pool timed out during a long merge; Dolt returned a lock-wait timeout under concurrent write load.","solutions":["Read the wrapped %w cause to identify the SQL error (table missing vs connection vs lock timeout).","If the conflict table no longer exists, the conflicts were likely already resolved — re-check conflict state before retrying.","For transient connection/lock errors, retry the whole auto-resolve (re-running the check pass first) rather than resuming mid-plan.","Ensure only one process at a time performs merge resolution on the repo to avoid concurrent clears."],"exampleFix":"// before — treating every ExecContext failure as fatal without inspecting the cause\n if err != nil { return fmt.Errorf(\"clear %s conflict: %w\", table, err) }\n// after — retry transient errors once with a fresh check pass\n if err != nil {\n     if errors.Is(err, driver.ErrBadConn) {\n         return retryAutoResolve(ctx, db, table) // re-runs unionConflictsAreSafe then resolve\n     }\n     return fmt.Errorf(\"clear %s conflict: %w\", table, err)\n }","handlingStrategy":"try-catch","validationCode":"// confirm the conflict table exists before resolving\nvar n int\nif err := db.QueryRowContext(ctx,\n\t\"SELECT COUNT(*) FROM information_schema.tables WHERE table_name = ?\",\n\t\"dolt_conflicts_\"+table).Scan(&n); err == nil && n == 0 {\n\treturn nil // nothing to resolve\n}","typeGuard":null,"tryCatchPattern":"err := resolveUnionConflicts(ctx, db, table, plan)\nif err != nil {\n\tvar driverErr *mysqldriver.MySQLError\n\tif errors.As(err, &driverErr) && isTransient(driverErr.Number) {\n\t\t// rebuild plan and retry once\n\t} else if strings.Contains(err.Error(), \"doesn't exist\") {\n\t\t// conflicts already cleared; treat as resolved\n\t} else {\n\t\treturn err\n\t}\n}","preventionTips":["Hold a single-writer lock on the repo during merge resolution.","Check conflict-table existence before each resolution run.","Retry the full check+resolve sequence on transient connection errors, not the resolve step alone.","Monitor connection-pool health for long merges."],"tags":["go","sql","dolt","merge-conflicts","database"],"backgroundTag":"sql-exec-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}