henrygd/beszel · error

failed to delete old container records: %v

Error message

failed to delete old container records: %v

What it means

deleteOldContainerRecords runs a DELETE on the containers collection for rows not updated in the last 10 minutes. Query execution failure is wrapped in this error, pointing at container-record retention cleanup.

Source

Thrown at internal/records/records_deletion.go:124

	// 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
}

// Deletes old quiet hours records where end date has passed
func deleteOldQuietHours(app core.App) error {
	now := time.Now().UTC()
	_, err := app.DB().NewQuery("DELETE FROM quiet_hours WHERE type = 'one-time' AND end < {:now}").Bind(dbx.Params{"now": now}).Execute()
	if err != nil {
		return err
	}

	return nil
}

View on GitHub (pinned to b38fb7dafa)

Solutions

  1. Inspect the wrapped error for the underlying SQLite cause
  2. Verify the containers collection exists and is not locked by another process
  3. Free disk space / resolve DB lock contention, then let the cleanup job retry
Defensive patterns

Strategy: try-catch

Validate before calling

if !collectionExists(app, "containers") {
    return errors.New("containers collection missing")
}

Try / catch

if err := deleteOldContainerRecords(app); err != nil {
    log.Error().Err(err).Msg("container retention cleanup failed")
    // inspect wrapped SQLite error, resolve lock/disk issue, retry
}

Prevention

When it happens

Trigger: The DELETE FROM containers query fails due to database lock, disk full, or the containers collection missing from the schema.

Common situations: SQLite lock contention with concurrent writes; schema drift after upgrades; full disk on the hub preventing writes.

Related errors


AI-assisted analysis of henrygd/beszel@b38fb7dafa (2026-08-31). Data as JSON: /api/errors/891d3c5d72131f31. Report an issue: GitHub.