Skip to content

Query timeout followed by health-check disconnect after repeated cancellations #163

Closed

Description

@albertorizzi

Observed behavior

On macOS with Tabularis 0.29.0, opening a small PostgreSQL table and running the corresponding SELECT manually both hang until the following error appears:

Plugin call 'execute_query' timed out after 120s

While the affected query was pending, a query against another table completed normally. After repeated attempts and cancellations, two consecutive health-check pings timed out and Tabularis disconnected the connection.

Expected behavior

Queries should complete or return an actionable error without preventing subsequent requests from completing.

Additional context

Possibly related to #160. The root cause has not been confirmed. The exact PostgreSQL plugin version still needs to be recorded.

Activity

  1. self-assigned this
    on Oct 22, 2026
  2. aesslinger commented on Oct 22, 2026

    @aesslinger
    Collaborator

    @albertorizzi — thanks, this is very useful and confirms what we're seeing in #160.

    Two details from your report line up exactly with the mechanism we've traced:

    • "a small table" hangs while "a query against another table completed normally" — this is the key signal. The hang is table-specific, driven by column types, not size. Tables with only built-in types (int, text, timestamptz, …) work; tables with at least one non-builtin type (custom enum, composite, domain, or an extension type like citext or Supabase's auth.uid) hang. Could you confirm: does the hanging table have any enum, custom domain, composite, or extension-defined column type? \d <table> in psql or the column list in Supabase's Table Editor will show it.
    • Tabularis 0.29.0 still hangs — this matters: 0.29.0 is the first version with the host-side pooler_mode field (#1128), and it does not fix this. That rules out the pooler_mode gate as a fix on its own, which matches our current diagnosis.

    The root cause (source-confirmed in tokio-postgres 0.7.18): in rc.9 (#149) we switched queries to the unnamed extended-query protocol. On the non-empty-rows path, tokio-postgres resolves each column's type during the response drain, and for non-builtin types it fires an internal named typeinfo_statement round-trip interleaved into that drain — which deadlocks on poolers that don't expect an out-of-order named statement mid-stream. rc.8's named path resolved types in a separate pre-Execute window, so it never interleaved. This is tracked as the same bug as #160; fix is in progress on branch fix/table-hang-pooler-160.

    One ask: the cascading part of your report — repeated cancellations → two health-check pings timed out → Tabularis disconnected — looks like a separate (secondary) issue in cancel/health-check handling rather than the query hang itself. Worth confirming: once we fix the hang, does the disconnect cascade still happen, or was it only ever a consequence of queries piling up? If it reproduces without a hanging query in play, please file it as its own issue so we can keep the two clean.

  3. albertorizzi commented on Oct 22, 2026

    @albertorizzi
    Author

    Thanks for the explanation. I can confirm that the affected table contains a custom PostgreSQL enum column.

    We observed the disconnect cascade only after queries hung and were repeatedly retried/cancelled. We have not reproduced it independently of a hanging query. We can retest once the fix is available.

  4. aesslinger commented on Oct 22, 2026

    @aesslinger
    Collaborator

    Update: the fix is on draft PR #164 and available for testing on branch fix/table-hang-pooler-160.

    To confirm the mechanism, here's what we verified:

    • Your table's custom enum column is exactly the trigger — tables with only built-in types work through the same pooler.
    • The root cause is tokio-postgres's internal prepared-statement handling for non-builtin column types under transaction-mode poolers, not your query or table size.

    Two things to try once the build is ready:

    1. Set the connection's Pooler Mode to "Transaction" in Tabularis. This activates the plugin's transaction-pooler-safe query path (pins the backend, clears stale statements, resolves column types before the data fetch). This is the plugin-side fix.

    2. If your pooler is PgBouncer-style, also set max_prepared_statements > 0 in pgbouncer.ini. This makes the pooler track prepared statements across reassignment — the best pooler-side fix, and it works without the plugin change too.

    If the hang persists after both, please share your pooler type (PgBouncer / Supavisor / other) and version, and whether max_prepared_statements is configurable on it. The disconnect cascade you saw should also disappear once the queries stop hanging — if it reproduces without a hanging query, that's a separate issue worth filing on its own.

  5. aesslinger commented on Oct 22, 2026

    @aesslinger
    Collaborator

    The query hang here has the same root cause as #160 (tokio-postgres's internal typeinfo_statement colliding across pooler backend reassignment on non-builtin column types), and the fix shipped in #164 (merged): a pinned one-shot transaction path for connections marked Pooler Mode = "Transaction" that pre-resolves column types while the backend is pinned and runs the unnamed-protocol data fetch.

    On the health-check disconnect: the PR's analysis is that the two consecutive health-check timeouts you saw were downstream fallout from the repeated hung/cancelled queries (a hung query holds the pooler backend; repeated cancellations stack), not an independent bug. The pinned path removes the hang, so the disconnect trigger should be gone with it.

    This is being released today in v1.0.0-rc.11.

    If the query hang or the health-check disconnect still reproduces on rc.11 (with the connection's Pooler Mode set to "Transaction"), please open a new issue — especially if the disconnect reproduces without a preceding hung query, which would make it an independent bug rather than downstream fallout, and we'd want to chase it separately.

  6. aesslinger commented on Oct 23, 2026

    @aesslinger
    Collaborator

    Follow-up: the rc.11 fix (#164) was incomplete for direct connections — see the note on #160. The query hang has the same root cause (a tokio-postgres typeinfo_statement interleave during Row deserialization that deadlocks on any connection once the response is large enough, not just pooler reassignment), and #164 only pre-resolved for Pooler Mode = "Transaction", leaving direct connections on the old hanging path (#166). A fix is in progress on fix/direct-enum-hang-166 that extends the pre-resolve to direct connections.

    On the health-check disconnect: as noted in the #164 analysis, the two consecutive health-check timeouts were downstream fallout from repeated hung/cancelled queries, not an independent bug. The worker-pool starvation that let stuck queries block the health-check pings is tracked separately in #167 (a src/main.rs architecture change — dedicated lanes for ping/connect — that deserves its own design). If either the hang or the disconnect still reproduces after the direct-connection fix lands, please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions