Skip to content

[4.x] Decode unsolicited ERR packets in MySQLDecoder - #1789

Merged
tsegismont merged 1 commit into
4.xfrom
backport/1787-to-4.x
Nov 10, 2026
Merged

tsegismont merged 1 commit into
4.xfrom
backport/1787-to-4.x

Conversation

@tsegismont

Copy link
Copy Markdown
Member

Backport of #1787 to 4.x
Cherry-picked commit: b9c4b4b

Fixes #1786

When the server closes an idle connection after `wait_timeout`, MySQL first sends an ERR packet (4031, `ER_CLIENT_INTERACTION_TIMEOUT`). With no command in flight, `MySQLDecoder` threw `IllegalStateException("No command codec for packet")` and the server's reason was lost.

`MySQLDecoder` now decodes an unsolicited ERR packet and fails with a `MySQLException`. Other unexpected packets still throw `IllegalStateException`.

`MySQLCommand#decodeErrorPacketPayload` and `MySQLCommand#readRestOfPacketString` are now `static` so the decoder can use them.

`MySQLPoolTest#testBorrowedPooledConnectionClosedByServer` now asserts that the connection `exceptionHandler` receives a `MySQLException` with error code 4031. The assertion is skipped on MariaDB, which closes the socket without sending an ERR packet.

Assisted-by: IBM Bob

Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
(cherry picked from commit b9c4b4b)
Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
@tsegismont
tsegismont merged commit e447fb6 into 4.x Nov 10, 2026
18 checks passed
@tsegismont
tsegismont deleted the backport/1787-to-4.x branch November 10, 2026 18:16
@tsegismont tsegismont added this to the 4.5.37 milestone Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant