{"record":{"id":"dfff1553c4a0affa","repo":"gastownhall/beads","slug":"iterate-inbound-dependencies-from-s-w","errorCode":null,"errorMessage":"iterate inbound dependencies from %s: %w","messagePattern":"iterate inbound dependencies from (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/issueops/delete.go","lineNumber":269,"sourceCode":"\t\t\tif err != nil {\n\t\t\t\tif optionalBlockedTable(depTable) && isTableNotExistError(err) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\treturn nil, fmt.Errorf(\"count inbound dependencies from %s: %w\", depTable, err)\n\t\t\t}\n\t\t\tfor rows.Next() {\n\t\t\t\tvar issID string\n\t\t\t\tif err := rows.Scan(&issID); err != nil {\n\t\t\t\t\t_ = rows.Close()\n\t\t\t\t\treturn nil, fmt.Errorf(\"scan inbound dependency: %w\", err)\n\t\t\t\t}\n\t\t\t\tif !deletedSet[issID] {\n\t\t\t\t\tdepsCount++\n\t\t\t\t}\n\t\t\t}\n\t\t\t_ = rows.Close()\n\t\t\tif err := rows.Err(); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"iterate inbound dependencies from %s: %w\", depTable, err)\n\t\t\t}\n\t\t}\n\t}\n\n\tresult.DependenciesCount = depsCount\n\tresult.LabelsCount = labelsCount\n\tresult.EventsCount = eventsCount\n\tresult.DeletedCount = len(set.RegularIDs) + len(set.WispIDs)\n\n\tif dryRun {\n\t\treturn result, nil\n\t}\n\n\taffectedIssues, affectedWisps, aerr := AffectedByDeletionInTx(ctx, tx, set.RegularIDs, set.WispIDs)\n\tif aerr != nil {\n\t\treturn nil, fmt.Errorf(\"affected by batch delete: %w\", aerr)\n\t}\n","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/issueops/delete.go#L251-L287","documentation":"DeleteResolvedSetInTx aborts when rows.Err() reports a failure after iterating an inbound-dependency result set. Unlike a scan error, this happens after the loop — the driver hit an I/O or protocol error while streaming rows (e.g. connection dropped mid-result-set). The failing dependency table is named in the message.","triggerScenarios":"Calling DeleteIssuesInTx/DeleteInTx where a large inbound-dependency result set is being streamed and the connection resets, the server kills the query, or the context deadline expires before iteration finishes.","commonSituations":"Very large dependency graphs with a short context timeout; Dolt server query timeout or memory limit; network instability between client and server.","solutions":["Unwrap to see whether it's a timeout, connection reset, or server-side kill.","Retry with a longer context timeout or smaller delete batches.","Check Dolt server logs for query kills around the failure.","Improve network reliability or run the delete locally against the database."],"exampleFix":"// before\nctx := context.Background()\nres, err := store.DeleteIssuesInTx(ctx, tx, ids)\n// after\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)\ndefer cancel()\nres, err := store.DeleteIssuesInTx(ctx, tx, ids)","handlingStrategy":"retry","validationCode":"if err := db.PingContext(ctx); err != nil {\n    return fmt.Errorf(\"connection unhealthy before large delete: %w\", err)\n}\n// ensure generous deadline\nif dl, ok := ctx.Deadline(); !ok || time.Until(dl) < 30*time.Second {\n    return errors.New(\"give inbound-dependency scans at least 30s\")\n}","typeGuard":null,"tryCatchPattern":"res, err := store.DeleteIssuesInTx(ctx, tx, ids)\nif err != nil && strings.Contains(err.Error(), \"iterate inbound dependencies\") {\n    return retryWithBackoff(3, func() error {\n        ctx2, cancel := context.WithTimeout(context.Background(), 5*time.Minute)\n        defer cancel()\n        _, err = store.DeleteIssuesInTx(ctx2, tx, ids)\n        return err\n    })\n}","preventionTips":["Delete large graphs in smaller batches to keep result sets small.","Raise Dolt server query timeout/memory limits for maintenance operations.","Prefer running bulk maintenance over a local/embedded connection."],"tags":["go","storage","sql","row-iteration","network"],"backgroundTag":"sql-row-iteration-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}