{"record":{"id":"b2c3517ab5f892db","repo":"gastownhall/beads","slug":"delete-drop-events-w","errorCode":null,"errorMessage":"delete: drop events: %w","messagePattern":"delete: drop events: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/issue_delete.go","lineNumber":190,"sourceCode":"\t// The SYNC-PLANE edges pointing at a deleted wisp, which are not the same\n\t// rows as the line above and are not reached by a foreign key: there is no\n\t// FK from dependencies to wisps, so `dependencies.depends_on_wisp_id` rows\n\t// survive their target unless they are deleted explicitly. Without this a\n\t// forced delete of a wisp left its durable dependent holding an edge into\n\t// a row that no longer exists — dangling, not orphaned, which is not what\n\t// issueops.DeleteRequest.Force promises. The store body has always done\n\t// this (issueops.deleteIssueRowInTx -> DeleteWispFromDependenciesInTx).\n\tif _, err := u.depRepo.DeleteAllForIDs(ctx, wispIDs, DepInsertOpts{}); err != nil {\n\t\treturn result, fmt.Errorf(\"delete: drop sync-plane edges into deleted wisps: %w\", err)\n\t}\n\tif _, err := u.labelRepo.DeleteAllForIDs(ctx, regularIDs, LabelOpts{}); err != nil {\n\t\treturn result, fmt.Errorf(\"delete: drop labels: %w\", err)\n\t}\n\tif _, err := u.labelRepo.DeleteAllForIDs(ctx, wispIDs, LabelOpts{UseWispsTable: true}); err != nil {\n\t\treturn result, fmt.Errorf(\"delete: drop wisp labels: %w\", err)\n\t}\n\tif _, err := u.eventsRepo.DeleteAllForIDs(ctx, regularIDs, RecordEventOpts{}); err != nil {\n\t\treturn result, fmt.Errorf(\"delete: drop events: %w\", err)\n\t}\n\tif _, err := u.eventsRepo.DeleteAllForIDs(ctx, wispIDs, RecordEventOpts{UseWispsTable: true}); err != nil {\n\t\treturn result, fmt.Errorf(\"delete: drop wisp events: %w\", err)\n\t}\n\n\tissuesDeleted, err := u.issueRepo.DeleteByIDs(ctx, regularIDs, IssueTableOpts{})\n\tif err != nil {\n\t\treturn result, fmt.Errorf(\"delete: drop issue rows: %w\", err)\n\t}\n\twispsDeleted, err := u.issueRepo.DeleteByIDs(ctx, wispIDs, IssueTableOpts{UseWispsTable: true})\n\tif err != nil {\n\t\treturn result, fmt.Errorf(\"delete: drop wisp rows: %w\", err)\n\t}\n\tresult.DeletedCount = issuesDeleted + wispsDeleted\n\n\tif params.UpdateTextReferences && len(connected) > 0 {\n\t\trefs, err := u.rewriteTextReferences(ctx, allIDs, connected, connectedIsWisp, actor)\n\t\tif err != nil {","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/issue_delete.go#L172-L208","documentation":"This error means deleting event rows for the regular issues being deleted failed. During deleteMany, eventsRepo.DeleteAllForIDs removes the issue history after labels; failure aborts the delete so events are never left for removed issues.","triggerScenarios":"DeleteIssue/DeleteIssues calls where the events table is unwritable (missing table, insufficient privileges, lock contention) or the connection/context fails during the cascade.","commonSituations":"Events table very large causing long DELETE times and lock wait timeouts; schema drift in embedded Dolt; DB restarted mid-operation.","solutions":["Confirm the events table exists and is writable; run migrations if stale.","Retry the delete; transactional scope prevents partial event removal.","Inspect the wrapped cause (lock timeout, disk full, permissions) and fix.","Archive/prune the events table if its size is causing timeouts."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if err := ctx.Err(); err != nil { return err }\nexists, err := tableExists(ctx, \"events\"); if err != nil || !exists { return fmt.Errorf(\"events table missing\") }\n// optionally prune: rows, _ := countRows(ctx, \"events\")","typeGuard":"var dbe *storage.DBError\nif errors.As(err, &dbe) { /* inspect driver cause */ }","tryCatchPattern":"if err := store.DeleteIssues(ctx, ids, opts); err != nil {\n    if strings.Contains(err.Error(), \"delete: drop events:\") { /* check lock timeouts / retry */ }\n}","preventionTips":["Prune/archive large events tables to keep deletes fast.","Keep adequate lock_wait_timeout for the driver.","Migrate stale schemas.","Set generous context deadlines for deletes."],"tags":["storage","database","delete","events"],"backgroundTag":"event-delete-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}