Skip to content

PdoPostgresAdapter owes the PostgreSQL reconnect-after-drop port (follow-up to #244) #245

Closed

Description

@tina4stack

PdoPostgresAdapter owes the PostgreSQL reconnect-after-drop port (follow-up to #244)

#244 brought PostgreSQL reconnect-after-drop to parity across the four frameworks' PRIMARY
adapters (Python #243, Node tina4stack/tina4-nodejs#163, Ruby tina4stack/tina4-ruby#143, and PHP's
ext-pgsql PostgresAdapter in #319, with negative tests in #320).

PHP has a SECOND adapter, Tina4/Database/PdoPostgresAdapter.php, used only as a fallback when
ext-pgsql (pg_connect) is absent but the pdo_pgsql PDO driver is present (see
Database::makePostgres). It still never re-establishes a dropped link.

To do (mirror #319 / the Python master)

  • Rebuild a dead link before a statement runs on it (never inside an explicit transaction).
  • Reconnect + retry once on a dropped-link error when no transaction owns the link; a failed
    reconnect leaves the link closed so the next statement recovers.
  • Surface transaction-control failures raw (no reconnect), and clear the in-transaction flag even
    if COMMIT/ROLLBACK fails on a dead link.
  • Real-PostgreSQL regression tests incl. the negatives from #320 (no mocks), gated by forcing the
    pdo_pgsql path (ext-pgsql unavailable) in the test environment.

🤖 Generated with Claude Code

Activity

  1. tina4stack commented on Oct 22, 2026

    @tina4stack
    OwnerAuthor

    Done in tina4stack/tina4-php#328 (merged to v3). PdoPostgresAdapter now reconnects after a dropped link — reactive reconnect in PdoAdapterTrait gated by a per-adapter connectionWasLost() hook (PG overrides it; SQLite/others unchanged), with the explicit-transaction gate cleared in a finally so a failed ROLLBACK can't wedge recovery. Mutation-proven by PdoPostgresReconnectTest on a real PostgreSQL (pg_terminate_backend, no mocks): positive + negative cases, red before the fix, green after. PostgreSQL reconnect-after-drop is now at full parity including PHP's PDO fallback.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions