Repository navigation
Cherry pick #107693 to 26.4: Length-encode the info field of the MySQL OK packet - #107822
Merged
robot-ch-test-poll3 merged 5 commits intoJun 18, 2026
Merged
Conversation
`MySQL Connector/J` 8.2.0 and newer (including 9.x) could not connect to the ClickHouse MySQL interface; the connection failed during driver setup with `Buffer length is less than expected payload length.` Root cause: `OKPacket::writePayloadImpl` wrote the `info` (human-readable status) field as a plain rest-of-packet string whenever `CLIENT_SESSION_TRACK` was not negotiated. The MySQL protocol documentation describes the field that way, but a real MySQL server length-encodes `info` unconditionally (verified on the wire against MySQL 8.0, which sends e.g. `... 0x28 "Rows matched: 2 Changed: 2 Warnings: 0"` even when the client did not request `CLIENT_SESSION_TRACK`). `Connector/J` >= 8.2 likewise reads `info` as a length-encoded string regardless of the negotiated capabilities. Because ClickHouse sends a non-empty summary (`Read N rows, ... in ... sec.`) in the result-set terminating `OK` packet, `Connector/J` interpreted the first byte of that summary (`R`, 0x52) as a length and failed. The driver issues the triggering query (`loadServerVariables`) while opening the connection, so the failure happens before any user query runs. Fix: always length-encode `info`, matching what a real MySQL server sends. `session_state_changes` is still only present when `CLIENT_SESSION_TRACK` and `SERVER_SESSION_STATE_CHANGED` are set. The human-readable summary is kept. Verified that `Connector/J` 9.3.0, `Connector/J` 8.1.0 and `PyMySQL` all connect successfully, and that the produced bytes match a real MySQL server. Closes: #84542 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The `mysql-java-client` integration image was pinned to `Connector/J` 8.1.0 because 8.2.0+ could not connect to the ClickHouse MySQL interface (the `info` field of the `OK` packet was written as a plain string while newer drivers read it length-encoded). Now that `info` is length-encoded, bump the driver to the current release (9.7.0) so the regression is covered. Verified that `MySQLJavaClientTest` produces output identical to `java_client.reference` with `Connector/J` 8.1.0, 9.3.0 and 9.7.0 (text and binary protocols), so no reference update is needed. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…connector-j-ok-packet
…or-j-ok-packet Length-encode the `info` field of the MySQL `OK` packet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Original pull-request #107693
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job