plandex-ai/plandex · critical
error getting active model stream: %v
Error message
error getting active model stream: %v
What it means
After the in-memory active-plan check, activatePlan queries db.GetActiveModelStream(plan.Id, branch). If that database call fails, the error is wrapped and returned as "error getting active model stream: %v". This is a storage/persistence failure during activation, not a business conflict.
Source
Thrown at app/server/model/plan/activate.go:41
sessionId string,
) (*types.ActivePlan, error) {
log.Printf("Activate plan: plan ID %s on branch %s\n", plan.Id, branch)
// Just in case this request was made immediately after another stream finished, wait a little to allow for cleanup
log.Println("Waiting 100ms before checking for active plan")
time.Sleep(100 * time.Millisecond)
log.Println("Done waiting, checking for active plan")
active := GetActivePlan(plan.Id, branch)
if active != nil {
log.Printf("Tell: Active plan found for plan ID %s on branch %s\n", plan.Id, branch) // Log if an active plan is found
return nil, fmt.Errorf("plan %s branch %s already has an active stream on this host", plan.Id, branch)
}
modelStream, err := db.GetActiveModelStream(plan.Id, branch)
if err != nil {
log.Printf("Error getting active model stream: %v\n", err)
return nil, fmt.Errorf("error getting active model stream: %v", err)
}
if modelStream != nil {
log.Printf("Tell: Active model stream found for plan ID %s on branch %s on host %s\n", plan.Id, branch, modelStream.InternalIp) // Log if an active model stream is found
return nil, fmt.Errorf("plan %s branch %s already has an active stream on host %s", plan.Id, branch, modelStream.InternalIp)
}
active = CreateActivePlan(
auth.OrgId,
auth.User.Id,
plan.Id,
branch,
prompt,
buildOnly,
autoContext,
sessionId,
)
View on GitHub (pinned to e2d772072e)
Solutions
- Read the wrapped cause (%v payload) and fix the underlying DB error (connectivity, auth, schema).
- Verify DB reachability and credentials from the server host.
- Run pending migrations so the active-model-stream schema exists.
- Retry activation after transient DB failures; add backoff on the caller side.
Example fix
// before: raw call without health guard
if !dbHealthy() { return errors.New("db not ready") }
_, err := db.GetActiveModelStream(planId, branch)
// after: retry transient DB errors
stream, err := db.GetActiveModelStream(planId, branch)
if isTransientDBErr(err) { time.Sleep(time.Second); stream, err = db.GetActiveModelStream(planId, branch) } Defensive patterns
Strategy: retry
Validate before calling
if err := db.Ping(); err != nil {
return fmt.Errorf("database unavailable before plan activation: %w", err)
} Try / catch
_, err := Tell(ctx, req)
if err != nil && strings.Contains(err.Error(), "error getting active model stream") {
// retry after DB recovers
time.Sleep(2 * time.Second)
_, err = Tell(ctx, req)
} Prevention
- Monitor DB health/latency before and during deploys
- Apply migrations before rolling out new server versions
- Use connection pooling with sane timeouts
- Alert on DB error rates to catch outages early
When it happens
Trigger: db.GetActiveModelStream returns a database error: DB connection failure, timeout, schema/migration mismatch, or locked database while another writer holds a transaction.
Common situations: Database unreachable after a deploy, expired DB credentials, migration lag where the model_streams table is missing a column, or sqlite/file DB lock contention.
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
- error storing model stream: %v
- error storing convo message description: %v
- error storing description: %v
- Error storing plan build result: %v
- error storing convo message: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/1a06e0112da9c338.
Report an issue: GitHub.