Skip to content

v2.1.0 – connection fixes

Latest

Choose a tag to compare

@g2px1 g2px1 released this 08 Sep 20:50
· 5 commits to main since this release
48576ed

upq v2.1.0

Fixed: connection parked with a reply already in the socket buffer

PgConnectionLibpq waited for readability as PQconsumeInput -> PQisBusy -> FIONREAD == 0 -> disarm_read() -> park. With the uvent poller running on another worker, an edge dispatched
between the FIONREAD probe and disarm_read() was erased, and the coroutine slept on a complete
reply (io deadline exceeded (... pending_bytes=131) in the watchdog diagnostics). The same
ordering existed in the COPY path and in the PQflush loop.

Now wait_readable() and wait_readable_for_listener() are self-contained:
disarm_read() -> FIONREAD -> park, so any caller ordering is safe; pump_input, the COPY reader
and flush_outgoing()/PQflush clear the hint before probing as well. Requires uvent v4.0.0:
its poller sets the READY hint on every edge, so a LISTEN loop that never cleared the hint would
spin. Verified with the uvent race stand (old ordering lost the wake-up in 112 of 218 iterations
with a 200 µs gap, new ordering 0 of 88 455) and with a pgbouncer churn stand
(pg_terminate_backend every 2 s + ALTER ROLE, 60 s, no stalls; docker pause of the pooler
recovers through the IO deadline).

Also since v2.0.5

  • Per-query IO deadline (QueryOpts::io_deadline_ms), transaction-scoped
    PgTransaction::set_io_deadline_ms, and watchdog diagnostics in the error message
    (waited_ms, deadline_ms, pending_bytes).
  • IO watchdog without a socket timer: a reaper coroutine per pool cuts awaits parked longer than
    the deadline via shutdown(2); the connection is then discarded.
  • Retry of transient pooler errors on a fresh connection (08P01 server_login_retry, 53300,
    57P03, 28P01 relayed by the pooler); PgPool::set_transient_retry(), counters in
    health_stats().
  • PgNotificationMultiplexer drains the socket fully per wake-up (NOTIFY bursts over one read
    were lost on edge-triggered pollers).
  • exec_param_query_nonblocking guards PQgetResult with PQisBusy (no blocking read on the
    worker).
  • Pluggable JSON backend (ujson / glaze / nlohmann / custom).
  • Go-style large export APIs (streaming, COPY, snapshots), auto leader detection, params support,
    compile-time parameter checking; security hardening (SQLi, memory DoS, data races).