2 Commits

Author SHA1 Message Date
e117b2acaa fix: discard MySQL dead connections (OperationalError/InterfaceError) from pool
Previously sqlorContext only discarded connections on RuntimeError/OSError
('closed'/'handler is closed'). MySQL OperationalError (2014 Command Out of
Sync) and InterfaceError (0 Not connected) were not caught, causing dead
connections to be returned to the pool and reused — cascading to multiple
500 errors on /llmage/v1/chat/completions.

Now catches any Exception with known MySQL dead-connection messages
(Not connected, Command Out of Sync, Lost connection, Connection reset,
Server disconnected) and discards the connection.

Added tests: mysql_error_during_use (5 variants), business_error_not_discarded.
2026-07-28 13:45:51 +08:00
33d332e36d fix: handle TCPTransport closed errors with connection health checks
- Add _check_alive() to verify connections before yielding from pool
- Discard dead connections and create fresh ones automatically
- Add _discard_sqlor() helper to safely remove broken connections
- Detect and handle 'closed'/'handler is closed' RuntimeError during use
- Add unit test for connection discard behavior
2026-06-27 17:53:21 +08:00