gastownhall/beads · error

clear conflict for %s %s: %w

Error message

clear conflict for %s %s: %w

What it means

This wraps the failure of the DELETE against dolt_conflicts_<table> that marks a conflict row as resolved. If this DELETE fails, dolt still considers the row in conflict even if the data UPDATE (theirs strategy) already succeeded. The %w wrap preserves the underlying SQL error for diagnosis.

Source

Thrown at internal/storage/versioncontrolops/conflicts.go:432

		// side under a --theirs invocation, undetectably. But zero is not
		// proof of that on its own (see conflictTargetStillPresent), so ask
		// before refusing: an operator who named this row deserves the abort
		// only when the row really is gone.
		if n, err := res.RowsAffected(); err != nil || n == 0 {
			present, err := conflictTargetStillPresent(ctx, db, table, keyCol, ourKey)
			if err != nil {
				return fmt.Errorf("confirm %s %s still exists after writing their values: %w", table, key, err)
			}
			if !present {
				return fmt.Errorf("their values for %s %s matched no row (was it deleted concurrently?); conflict left unresolved", table, key)
			}
		}
	}

	del := fmt.Sprintf("DELETE FROM `dolt_conflicts_%s` WHERE `our_%s` = ?", table, keyCol) //nolint:gosec // identifiers validated
	res, err := db.ExecContext(ctx, del, ourKey)
	if err != nil {
		return fmt.Errorf("clear conflict for %s %s: %w", table, key, err)
	}
	if n, err := res.RowsAffected(); err == nil && n == 0 {
		return fmt.Errorf("conflict for %s %s was not cleared (no conflict row deleted)", table, key)
	}
	return nil
}

// GetMergeBlockers reports the merge state that `bd conflicts` cannot show as
// rows: whether a merge is open at all, plus the schema conflicts and
// constraint violations that make dolt refuse the merge commit even when
// every dolt_conflicts row is resolved (wy-36ilm F12). Without it, that state
// surfaced only as a raw dolt error from CommitMergeResolution, after the
// operator had been told "0 conflicts remain".
//
// Each source is read independently and a MISSING source table is not an
// error: dolt_schema_conflicts and dolt_constraint_violations are dolt system
// tables whose presence has varied across versions, and a diagnosis helper
// must never be the thing that fails the command.

View on GitHub (pinned to 71377f2769)

Solutions

  1. Inspect the wrapped cause and fix the underlying SQL/connection error first (connectivity, permissions, deadline).
  2. Retry ResolveConflictRows for the affected row once the connection is healthy; per-row resolution is idempotent.
  3. Increase the context timeout or run resolution on a single healthy connection/session.
  4. Check dolt sql-server (or embedded engine) logs if the wrapped cause is opaque.

Example fix

// before: one long, cancellation-prone call
ctx := context.Background()
err := ops.ResolveConflictRows(ctx, db, "issues", "theirs", keys)
// after: bounded, retryable context
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()
var lastErr error
for i := 0; i < 3; i++ {
  lastErr = ops.ResolveConflictRows(ctx, db, "issues", "theirs", keys)
  if lastErr == nil { break }
  time.Sleep(time.Duration(i+1) * time.Second)
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure the DB is reachable and writable before resolving:
if err := db.PingContext(ctx); err != nil { return err }

Try / catch

if err := ops.ResolveConflictRows(ctx, db, table, "theirs", keys); err != nil {
  log.Printf("clear conflict failed: %v", err) // %w chain shows SQL cause
  if isTransient(err) { return retryWithBackoff(ctx, db, table, keys) }
  return err
}

Prevention

When it happens

Trigger: Any error from ExecContext on DELETE FROM dolt_conflicts_<table> WHERE our_<keycol> = ? during ResolveConflictRows: connection drop, context cancellation, dolt storage-engine error, permission failure on the conflict table, or a database state that rejects writes (e.g. mid-merge lock).

Common situations: Network interruption between client and dolt sql-server; context timeout expiring mid-resolution; concurrent schema changes; permissions issues on dolt system conflict tables in server mode.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/26c9f31e3bffb4bb. Report an issue: GitHub.