{"record":{"id":"176a23dbd29d025f","repo":"gastownhall/beads","slug":"iterate-schema-conflicts-w","errorCode":null,"errorMessage":"iterate schema conflicts: %w","messagePattern":"iterate schema conflicts: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/versioncontrolops/conflicts.go","lineNumber":510,"sourceCode":"func schemaConflictTables(ctx context.Context, db DBConn) ([]string, error) {\n\trows, err := db.QueryContext(ctx, \"SELECT table_name FROM dolt_schema_conflicts\")\n\tif err != nil {\n\t\tif isMissingSystemTable(err) {\n\t\t\treturn nil, nil\n\t\t}\n\t\treturn nil, fmt.Errorf(\"query schema conflicts: %w\", err)\n\t}\n\tdefer func() { _ = rows.Close() }()\n\tvar tables []string\n\tfor rows.Next() {\n\t\tvar t string\n\t\tif err := rows.Scan(&t); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"scan schema conflict: %w\", err)\n\t\t}\n\t\ttables = append(tables, t)\n\t}\n\tif err := rows.Err(); err != nil {\n\t\treturn nil, fmt.Errorf(\"iterate schema conflicts: %w\", err)\n\t}\n\treturn tables, nil\n}\n\n// constraintViolationCounts lists the tables carrying outstanding constraint\n// violations. mergesettle.go repairs the FK-cascade class on the auto path;\n// anything it declined lands here, blocking the commit.\nfunc constraintViolationCounts(ctx context.Context, db DBConn) ([]storage.ConstraintViolation, error) {\n\trows, err := db.QueryContext(ctx,\n\t\t\"SELECT `table`, num_violations FROM dolt_constraint_violations WHERE num_violations > 0\")\n\tif err != nil {\n\t\tif isMissingSystemTable(err) {\n\t\t\treturn nil, nil\n\t\t}\n\t\treturn nil, fmt.Errorf(\"query constraint violations: %w\", err)\n\t}\n\tdefer func() { _ = rows.Close() }()\n\tvar out []storage.ConstraintViolation","sourceCodeStart":492,"sourceCodeEnd":528,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/versioncontrolops/conflicts.go#L492-L528","documentation":"After scanning all rows from dolt_schema_conflicts, rows.Err() returned non-nil — the result-set iteration itself failed (connection drop, context cancellation, or engine error mid-stream). This is a transport/engine-level failure while reading the list, not a data problem.","triggerScenarios":"GetMergeBlockers iterating dolt_schema_conflicts when the connection drops, the context is cancelled, the dolt sql-server closes the result set, or the embedded engine errors mid-read (e.g. storage fault during a large conflict listing).","commonSituations":"Long interactive sessions where the connection times out during diagnosis; context deadlines expiring on slow servers; network flakiness between bd and a remote dolt sql-server.","solutions":["Retry GetMergeBlockers on a fresh connection/context; a mid-iteration rows.Err is usually transient.","Raise the context timeout and the driver's read timeout if the conflict list is large or the server is slow.","Check the dolt sql-server logs for the corresponding server-side error (disconnect, OOM, storage fault).","Fix connection-pool settings (e.g. max lifetime) if connections are reclaimed mid-query."],"exampleFix":"// before: single attempt, cancels on slow server\nblockers, err := ops.GetMergeBlockers(ctx, db)\n// after: retry transient failures with a longer deadline\nrun := func() (storage.MergeBlockers, error) {\n  c, cancel := context.WithTimeout(ctx, 120*time.Second)\n  defer cancel()\n  return ops.GetMergeBlockers(c, db)\n}\nblockers, err := run()\nif err != nil && isTransient(err) { blockers, err = run() }","handlingStrategy":"retry","validationCode":"// Check connectivity before iterating large result sets:\nif err := db.PingContext(ctx); err != nil { return err }\nctx, cancel := context.WithTimeout(ctx, 120*time.Second); defer cancel()","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"iterate schema conflicts\") {\n  time.Sleep(2 * time.Second)\n  blockers, err = ops.GetMergeBlockers(freshCtx, freshDB) // retry once\n}","preventionTips":["Use generous context timeouts for merge diagnostics.","Enable driver keepalives/reconnect for long sessions.","Avoid cancelling the request mid-listing; let the iteration complete."],"tags":["dolt","result-set-iteration","network","diagnostics"],"backgroundTag":"result-set-iteration-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}