Repository navigation
Commit e3012f4
committed
Close connections that stall or stay idle
The login timeout only covered clients that had not logged in yet, so a
logged-in client could stay connected without sending anything and keep one of
the connection slots forever. Writes also blocked, so a client that stopped
reading a large result stalled the whole proxy, and no timeout could run.
Give every connection a single deadline: LOGIN_TIMEOUT until it logs in, then
IDLE_TIMEOUT after each request. While a request or a response is only partly
transferred, READ_TIMEOUT or WRITE_TIMEOUT applies instead, and each transferred
part restarts it. The limits match MySQL's connect_timeout, wait_timeout,
net_read_timeout, and net_write_timeout defaults. Data from a client that has
not logged in does not extend its login deadline. Deadlines use the monotonic
hrtime() where PHP has it.
Make client sockets non-blocking. Keep a response the client has not accepted
yet, and stop reading from that client until it does, so the proxy holds at
most one response per client. Read up to 64 KB at a time.1 parent 4b4ffa0 commit e3012f4
3 files changed
Lines changed: 501 additions & 117 deletions
File tree
- packages/mysql-proxy
- src
- tests
0 commit comments