Skip to content

pg push schema maintenance can block pg serve dashboards #887

Description

@flexiondotorg

agentsview version

0.34.5

Install method

Other / not sure

OS / platform

NixOS 26.05

Which agent and version

Claude Code, Pi Agent, Codex, Open Code, Hermes (all latest)

Which model(s)

opus-4.8 and gpt-5.5

What happened, and what did you expect

Follow-up to #605.

The fastupdate=off fix works. The index is now bounded and no longer grows unbounded.

A new problem remains: pg push still runs EnsureSchema() before every sync. That includes:

CREATE INDEX IF NOT EXISTS ...
ALTER INDEX idx_messages_content_trgm SET (fastupdate = off)

On a shared PostgreSQL server with several sync clients, these DDL statements can wait on locks. Dashboard reads then queue behind them and the web UI shows “request timed out”.

Expected behaviour:

pg push should not run schema/index maintenance during every sync against an existing shared database.

Suggested fix:

Split schema maintenance from sync, or make pg push skip DDL when the schema is already current.

Sample session file or snippet

Triage:

  • Caddy was healthy.
  • pg serve was healthy.
  • Static assets and small APIs returned 200.
  • Slow dashboard APIs timed out.
  • PostgreSQL showed ALTER INDEX waiting, CREATE INDEX waiting, and dashboard SELECT queries waiting.
  • Autovacuum logged skipping vacuum ... lock not available.
  • Setting lock_timeout = '2s' on the agentsview role and reconnecting clients cleared the issue.

Not a parse/render/usage bug. This is a PostgreSQL pg push / pg serve lock contention bug.

Relevant live PostgreSQL evidence:

ALTER INDEX idx_messages_content_trgm SET (fastupdate = off) waiting
CREATE INDEX IF NOT EXISTS ... waiting
dashboard SELECT queries waiting
autovacuum: skipping vacuum of "sessions" --- lock not available

Slow dashboard endpoints timed out:

/api/v1/analytics/sessions  timed out after 30s
/api/v1/analytics/activity  timed out after 30s
/api/v1/analytics/velocity  timed out after 30s

Steps to reproduce

  1. Set up a shared PostgreSQL backend for AgentsView.
  2. Run agentsview pg serve against that database.
  3. Run several agentsview pg push clients against the same database.
  4. Open the web dashboard and load analytics views.
  5. Observe dashboard requests timing out while PostgreSQL shows CREATE INDEX or ALTER INDEX waiting on locks.

Workaround tested:

ALTER ROLE agentsview SET lock_timeout = '2s';
ALTER ROLE agentsview SET idle_in_transaction_session_timeout = '30s';

Then reconnect existing agentsview PostgreSQL clients.

Checklist

  • I searched existing issues
  • I removed secrets and private data from any attached session files

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions