{"record":{"id":"93e96d241d1caa9f","repo":"crowdsecurity/crowdsec","slug":"decision-with-alert-id-d-w","errorCode":null,"errorMessage":"decision with alert ID '%d': %w","messagePattern":"decision with alert ID '(.+?)': %w","errorType":"exception","errorClass":"DeleteFail","httpStatus":null,"severity":"error","filePath":"pkg/database/alerts.go","lineNumber":955,"sourceCode":"\tif err != nil {\n\t\tc.Log.Warningf(\"DeleteAlertGraph : %s\", err)\n\t\treturn fmt.Errorf(\"event with alert ID '%d': %w\", alertItem.ID, DeleteFail)\n\t}\n\n\t// delete the associated meta\n\t_, err = c.Ent.Meta.Delete().\n\t\tWhere(meta.HasOwnerWith(alert.IDEQ(alertItem.ID))).Exec(ctx)\n\tif err != nil {\n\t\tc.Log.Warningf(\"DeleteAlertGraph : %s\", err)\n\t\treturn fmt.Errorf(\"meta with alert ID '%d': %w\", alertItem.ID, DeleteFail)\n\t}\n\n\t// delete the associated decisions\n\t_, err = c.Ent.Decision.Delete().\n\t\tWhere(decision.HasOwnerWith(alert.IDEQ(alertItem.ID))).Exec(ctx)\n\tif err != nil {\n\t\tc.Log.Warningf(\"DeleteAlertGraph : %s\", err)\n\t\treturn fmt.Errorf(\"decision with alert ID '%d': %w\", alertItem.ID, DeleteFail)\n\t}\n\n\t// delete the alert\n\terr = c.Ent.Alert.DeleteOne(alertItem).Exec(ctx)\n\tif err != nil {\n\t\tc.Log.Warningf(\"DeleteAlertGraph : %s\", err)\n\t\treturn fmt.Errorf(\"alert with ID '%d': %w\", alertItem.ID, DeleteFail)\n\t}\n\n\treturn nil\n}\n\nfunc (c *Client) DeleteAlertByID(ctx context.Context, id int) error {\n\talertItem, err := c.Ent.Alert.Query().Where(alert.IDEQ(id)).Only(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n","sourceCodeStart":937,"sourceCodeEnd":973,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/database/alerts.go#L937-L973","documentation":"DeleteAlertGraph deletes the alert's decisions after events and meta. This error means the Decision DELETE failed, leaving events/meta already removed but decisions and the alert intact. Wraps the DeleteFail sentinel.","triggerScenarios":"DeleteAlertByID(ctx, id) -> DeleteAlertGraph: Decision.Delete().Where(decision.HasOwnerWith(alert.IDEQ(alertItem.ID))) fails — DB unavailable, FK/lock issues from an active bouncer reading decisions, or missing grants.","commonSituations":"Lock contention because bouncers continuously SELECT from decisions while LAPI deletes; DB connection loss; migration mismatch on the decisions table.","solutions":["Check the 'DeleteAlertGraph : %s' warning for the root cause","Retry DeleteAlertByID; the operation is safe to re-run","Check for lock contention with active bouncer queries on decisions","Verify DB user DELETE grants on decisions"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// decisions may be actively read by bouncers; check DB lock pressure first\nn, err := client.Ent.Decision.Query().Where(decision.HasOwnerWith(alert.IDEQ(id))).Count(ctx)\nif err != nil { /* DB unhealthy, skip delete */ }","typeGuard":null,"tryCatchPattern":"err := client.DeleteAlertByID(ctx, id)\nif err != nil && errors.Is(err, entdb.DeleteFail) {\n    // decisions stage failed; check for bouncer read contention\n}","preventionTips":["Schedule alert cleanup away from peak bouncer query times","Ensure DELETE grants on decisions","Check for long-running transactions blocking decisions","Retry once before escalating"],"tags":["database","delete","decisions"],"backgroundTag":"database-write-failed","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}