Restore Stable PostgreSQL I/O and reduce scheduler work

Merged
RE
12d ago
+745-108

Addresses the correctness and scheduler findings in #6568, on top of #6532.

  • Restore Stable's original PostgreSQL poll-time I/O and handler API; gate deferred readiness and TLS handshake caching with PROXYSQL31.
  • Preserve queued output on retryable plaintext send failures on both tiers.
  • Process backend responses before new frontend work, skip unnecessary late scans, and publish only the requested MySQL hostgroup's cached connections.
  • Batch terminal continuation cleanup and dispatch capacity released by deletion. Add socket, ordering, cache-scope, paused-session and cleanup regressions.

Validation: Stable and v3.1 release/debug builds passed. The v3.1 release and debug suites each passed 261 assertions; focused Stable checks and real native/libpq waiter-ordering checks passed. Throughput improvement has not been established.


Summary by cubic

Restores Stable's original PostgreSQL poll-time I/O and handler API, and reduces scheduler work by processing backend responses first and skipping unnecessary scans.

  • Deferred readiness and TLS handshake caching stay gated behind PROXYSQL31; Stable keeps its original socket I/O in the poll scan.
  • Retryable plaintext send failures now preserve queued output on both MySQL and PostgreSQL tiers instead of closing healthy slow clients.
  • Backend responses are dispatched before new frontend work; late scans are skipped when no backend work is pending.
  • Normal checkout recovery publishes only the requested MySQL hostgroup's cached connections, leaving compatible caches for other hostgroups intact.
  • Terminal continuation cleanup is batched into a single traversal, with released capacity dispatched to waiters in the same pass.
  • Adds real-socket and scheduler-cost regression tests covering poll boundaries, paused disconnects, retryable sends, targeted cache publication, and cleanup ordering.

Summary by CodeRabbit

  • Bug Fixes
    • Cached MySQL connections are now returned only for the requested hostgroup, helping prevent connections from unrelated hostgroups being used.
    • PostgreSQL connections better handle temporary send interruptions: queued data is retained for retry, while fatal send errors close the stream.
    • Worker scheduling now performs cleanup and capacity handling more consistently, including for paused or terminated sessions.
  • Compatibility
    • PostgreSQL polling and session handling retain build-specific behavior across Stable and ProxySQL 3.1 configurations.