henrygd/beszel · error
failed to delete old systemd service records: %v
Error message
failed to delete old systemd service records: %v
What it means
deleteOldSystemdServiceRecords runs a DELETE on the systemd_services collection for rows not updated in the last 20 minutes. A failed query execution is wrapped in this error, identifying the systemd retention cleanup as the failing step.
Source
Thrown at internal/records/records_deletion.go:110
conditionStr := strings.Join(conditionParts, " OR ")
// Construct and execute the full raw query
rawQuery := fmt.Sprintf("DELETE FROM %s WHERE %s", collection, conditionStr)
if _, err := app.DB().NewQuery(rawQuery).Bind(params).Execute(); err != nil {
return fmt.Errorf("failed to delete from %s: %v", collection, err)
}
}
return nil
}
// Deletes systemd service records that haven't been updated in the last 20 minutes
func deleteOldSystemdServiceRecords(app core.App) error {
now := time.Now().UTC()
twentyMinutesAgo := now.Add(-20 * time.Minute)
// Delete systemd service records where updated < twentyMinutesAgo
_, err := app.DB().NewQuery("DELETE FROM systemd_services WHERE updated < {:updated}").Bind(dbx.Params{"updated": twentyMinutesAgo.UnixMilli()}).Execute()
if err != nil {
return fmt.Errorf("failed to delete old systemd service records: %v", err)
}
return nil
}
// Deletes container records that haven't been updated in the last 10 minutes
func deleteOldContainerRecords(app core.App) error {
now := time.Now().UTC()
tenMinutesAgo := now.Add(-10 * time.Minute)
// Delete container records where updated < tenMinutesAgo
_, err := app.DB().NewQuery("DELETE FROM containers WHERE updated < {:updated}").Bind(dbx.Params{"updated": tenMinutesAgo.UnixMilli()}).Execute()
if err != nil {
return fmt.Errorf("failed to delete old container records: %v", err)
}
return nil
}View on GitHub (pinned to b38fb7dafa)
Solutions
- Inspect the wrapped error for the SQLite root cause (locked/disk full/no such table)
- Confirm the systemd_services collection exists in the current PocketBase schema
- Check disk space and DB lock contention around the cleanup schedule
Defensive patterns
Strategy: try-catch
Validate before calling
if !collectionExists(app, "systemd_services") {
return errors.New("systemd_services collection missing")
} Try / catch
if err := deleteOldSystemdServiceRecords(app); err != nil {
log.Error().Err(err).Msg("systemd service retention cleanup failed")
// check for SQLite lock/disk errors and retry later
} Prevention
- Confirm systemd_services collection exists after upgrades
- Schedule cleanup away from backup jobs holding DB locks
- Monitor disk usage and DB error logs
When it happens
Trigger: The DELETE FROM systemd_services query fails: database locked, disk full, or the systemd_services collection missing/renamed in the schema.
Common situations: SQLite lock contention during cleanup cron; upgraded instances where the systemd_services collection was renamed; disk exhaustion on the hub host.
Related errors
- failed to delete from %s: %v
- failed to delete old container records: %v
- service name is required
- systemd manager unavailable
- failed to find systems collection: %v
AI-assisted analysis of henrygd/beszel@b38fb7dafa (2026-08-31).
Data as JSON: /api/errors/bff21ef69241074d.
Report an issue: GitHub.