crowdsecurity/crowdsec · error · DeleteFail
alert graph delete batch meta
Error message
alert graph delete batch meta: %w
What it means
DeleteAlertGraphBatch deletes meta rows owned by the alerts in idList; on failure it logs the raw error and returns DeleteFail wrapped. Events deletion had succeeded (or was skipped) but the meta cleanup failed, potentially leaving orphaned meta rows.
Solutions
- Check the preceding Warningf log for the raw driver error
- Retry DeleteAlertGraphBatch; deletion is per-graph step so re-running is safe for cleanup
- Reduce batch size if IN-clause limits are implicated
- Inspect for orphaned meta rows if the failure persists and clean with a manual delete by alert_id
Defensive patterns
Strategy: retry
Validate before calling
if len(idList) == 0 {
return nil
} Try / catch
_, err := client.DeleteAlertGraphBatch(ctx, ids)
if err != nil {
// safe to retry; verify meta cleanup afterwards
return retryAfterCleanup(ctx, ids)
} Prevention
- Keep batch sizes within driver IN-clause limits
- Serialize large deletions against concurrent alert writes
- Periodically check for orphaned meta/decision rows after failed deletes
When it happens
Trigger: c.Ent.Meta.Delete().Where(meta.HasOwnerWith(alert.IDIn(...))).Exec(ctx) fails — DB connectivity, lock contention, oversized ID list, context cancelled.
Common situations: Large batch alert deletion against SQLite under lock contention; connection dropped between the event and meta delete statements; MySQL deadlock with a concurrent alert writer.
Related errors
- alert graph delete batch events
- alert with ID
- alert graph delete batch decisions
- alert graph delete batch
- could not delete alerts
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/239ca63d30848841.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/database/alerts.go:911
func (c *Client) DeleteAlertGraphBatch(ctx context.Context, alertItems []*ent.Alert) (int, error) {
idList := make([]int, 0)
for _, alert := range alertItems {
idList = append(idList, alert.ID)
}
_, err := c.Ent.Event.Delete().
Where(event.HasOwnerWith(alert.IDIn(idList...))).Exec(ctx)
if err != nil {
c.Log.Warningf("DeleteAlertGraphBatch : %s", err)
return 0, fmt.Errorf("alert graph delete batch events: %w", DeleteFail)
}
_, err = c.Ent.Meta.Delete().
Where(meta.HasOwnerWith(alert.IDIn(idList...))).Exec(ctx)
if err != nil {
c.Log.Warningf("DeleteAlertGraphBatch : %s", err)
return 0, fmt.Errorf("alert graph delete batch meta: %w", DeleteFail)
}
_, err = c.Ent.Decision.Delete().
Where(decision.HasOwnerWith(alert.IDIn(idList...))).Exec(ctx)
if err != nil {
c.Log.Warningf("DeleteAlertGraphBatch : %s", err)
return 0, fmt.Errorf("alert graph delete batch decisions: %w", DeleteFail)
}
deleted, err := c.Ent.Alert.Delete().
Where(alert.IDIn(idList...)).Exec(ctx)
if err != nil {
c.Log.Warningf("DeleteAlertGraphBatch : %s", err)
return deleted, fmt.Errorf("alert graph delete batch: %w", DeleteFail)
}
c.Log.Debug("Done batch delete alerts")
View on GitHub (pinned to 909b515798)