vxcontrol/pentagi · error
failed to update container status to deleted: %w
Error message
failed to update container status to deleted: %w
What it means
The Docker container was removed successfully, but marking the DB row as ContainerStatusDeleted failed. The row would go stale (still showing the container as present) while the real container is gone.
Source
Thrown at backend/pkg/docker/client.go:777
options := client.ContainerRemoveOptions{
RemoveVolumes: true,
Force: true,
}
if _, err := dc.client.ContainerRemove(ctx, containerID, options); err != nil {
if !cerrdefs.IsNotFound(err) {
return fmt.Errorf("failed to remove container: %w", err)
}
// already gone (removed manually, or a prior call already succeeded);
// still mark it deleted below so the database row does not go stale.
logger.WithError(err).Warn("container not found")
}
_, err := dc.db.UpdateContainerStatus(ctx, database.UpdateContainerStatusParams{
Status: database.ContainerStatusDeleted,
ID: dbID,
})
if err != nil {
return fmt.Errorf("failed to update container status to deleted: %w", err)
}
logger.Info("container removed")
return nil
}
func (dc *dockerClient) Cleanup(ctx context.Context) error {
logger := dc.logger.WithContext(ctx).WithField("docker", "cleanup")
logger.Info("cleaning up containers and making all flows finished...")
flows, err := dc.db.GetFlows(ctx)
if err != nil {
return fmt.Errorf("failed to get all flows: %w", err)
}
containers, err := dc.db.GetContainers(ctx)
if err != nil {View on GitHub (pinned to ea665308ba)
Solutions
- Check database connectivity and whether the backend is pointed at a read-only replica
- Inspect row locks (`pg_locks`, `pg_stat_activity`) for blocking transactions and resolve them
- Retry the update; since the container is already removed, this is a bookkeeping-only operation
- Add an idempotency guard: if the row is already deleted or missing, treat the update as done
Defensive patterns
Strategy: retry
Try / catch
if err := dc.RemoveContainer(ctx, id, dbID); err != nil {
if strings.Contains(err.Error(), "status to deleted") {
// container already gone; reconcile row later
reconcileQueue.Add(dbID)
}
} Prevention
- Serialize status updates per container row (advisory lock or unique worker)
- Use short backoff retries for bookkeeping updates
- Ensure the backend never writes through a read-only replica
- Run a periodic reconciler that marks rows deleted for missing containers
When it happens
Trigger: dc.db.UpdateContainerStatus with Status=ContainerStatusDeleted errors: lost DB connection, deadlock/lock timeout on the containers row, concurrent delete of the row, or constraint violation.
Common situations: Postgres failover or pool exhaustion during cleanup; two teardown paths racing to update the same dbID; long transaction holding a row lock; backend reconnected to a read-only replica.
Related errors
- failed to create tool call log: %w
- failed to update tool call log result: %w
- failed to update tool call log failed result: %w
- failed to create termlog: %w
- failed to get containers: %w
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/48f18b1e94383c72.
Report an issue: GitHub.