Drains MySQL handshake greeting before closing a connection to avoid RST.
// Source: https://github.com/gastownhall/beads | License: MIT | Copyright 2025 Beads Contributors // Provided via justclaw.it.com; keep this notice with the code. package doltserver import ( "net" "time" ) // DrainAndCloseProbe drains the MySQL handshake greeting (if any) from conn // before closing it, then closes the connection. // // A bare Close() on a connection that hasn't read the server's handshake // packet causes the OS to send a TCP RST instead of a clean FIN. Dolt's // sql-server interprets that RST as an aborted MySQL handshake; enough of // them in a short window (e.g. from repeated readiness/circuit-breaker // probes) can crash the dolt sql-server process. Reading the greeting first // — even partially — lets the TCP stack close cleanly instead. See // gastownhall/beads ... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key