vxcontrol/pentagi · error
failed to get all flows: %w
Error message
failed to get all flows: %w
What it means
Cleanup starts by fetching every flow row to mark flows finished and stop containers; this error wraps a failure of that initial GetFlows query. No cleanup work has been performed when it is returned.
Source
Thrown at backend/pkg/docker/client.go:791
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 {
return fmt.Errorf("failed to get all containers: %w", err)
}
flowsStatusMap := make(map[int64]database.FlowStatus)
for _, flow := range flows {
flowsStatusMap[flow.ID] = flow.Status
}
flowContainersMap := make(map[int64][]database.Container)
for _, container := range containers {
flowContainersMap[container.FlowID] = append(flowContainersMap[container.FlowID], container)
}
var wg sync.WaitGroup
removeContainer := func(containerID string, dbID int64) {View on GitHub (pinned to ea665308ba)
Solutions
- Verify database connectivity and that all goose migrations are applied
- Check for table-level locks on flows (`pg_locks`) and terminate blocking sessions
- Retry Cleanup after the database is healthy — it is safe to re-run since it is idempotent in intent
- Review backend logs for the underlying pq/pgx error code to distinguish connectivity vs schema issues
Defensive patterns
Strategy: retry
Validate before calling
if err := db.PingContext(ctx); err != nil {
return fmt.Errorf("database unavailable, deferring cleanup: %w", err)
} Try / catch
if err := dc.Cleanup(ctx); err != nil {
if strings.Contains(err.Error(), "failed to get all flows") {
// DB was unavailable; re-run cleanup after recovery
scheduleRetry(ctx, dc.Cleanup)
}
} Prevention
- Verify all goose migrations are applied before backend startup
- Delay startup cleanup until the DB health check passes
- Monitor Postgres availability with readiness probes
- Keep the flows table free of long-held locks
When it happens
Trigger: dc.db.GetFlows fails at Cleanup start: database unreachable, query timeout, corrupted/locked table, or a schema mismatch (migration not applied).
Common situations: Postgres down or restarting at backend shutdown/startup when Cleanup runs; network partition to the DB; pending goose migration leaving the flows table in an unexpected schema; connection pool exhausted.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- failed to get all containers: %w
- 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
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/0ebd1f23d6b60f5e.
Report an issue: GitHub.