feat(tidb-stmt-cache): add a streamed-BLOB fixture for SEND_LONG_DATA - #151
Merged
Conversation
keploy/keploy#4262: writing a BLOB through PreparedStatement.setBinaryStream on a server-side prepared statement makes Connector/J 8.x send the value out of band and pipeline three commands per re-execution without reading a response in between: COM_STMT_RESET -> COM_STMT_SEND_LONG_DATA -> COM_STMT_EXECUTE A long-sent parameter is absent from the EXECUTE payload while still being non-NULL in the null bitmap, so a decoder that reads a value for every non-NULL parameter runs off the end and rejects the command. The EXECUTE never reaches the recorder, and replay fails with "Can not read response from server". Nothing in the suite wrote a BLOB through a stream setter, so the sequence was never recorded. This adds the fixture that produces it: - blob_stream table in SchemaInitializer, alongside kv. - GET /api/blob/{size} inserts a payload with setBinaryStream (not setBytes — the stream setter is what triggers SEND_LONG_DATA), then reads LENGTH(payload) back. The endpoint has to be driven more than once: the RESET only appears when the statement is re-executed from Connector/J's cache, which this sample already enables via useServerPrepStmts + cachePrepStmts. Verified against keploy at 05b4eada and against the #4262 fix — the recorded mocks go from 0 COM_STMT_EXECUTE to 6, and replay with TiDB stopped goes from 1 passed / 3 failed (6 "Can not read response from server") to 4 passed. Signed-off-by: slayerjain <shubham@keploy.io>
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.
Describe the changes that are made
Adds the fixture that reproduces keploy/keploy#4262.
Writing a BLOB through
PreparedStatement.setBinaryStreamon a server-side prepared statement makes Connector/J 8.x send the value out of band and pipeline three commands per re-execution, without reading a response in between:A long-sent parameter is absent from the EXECUTE payload while still being non-NULL in the null bitmap. A decoder that reads a value for every non-NULL parameter therefore runs off the end and rejects the command — so the EXECUTE never reaches the recorder at all, and replay fails with
Can not read response from server.Nothing in the suite wrote a BLOB through a stream setter, which is why the sequence was never recorded.
SchemaInitializer— adds ablob_streamtable alongsidekv.QueryController—GET /api/blob/{size}inserts a payload withsetBinaryStream(deliberately notsetBytes; the stream setter is what triggersSEND_LONG_DATA), then readsLENGTH(payload)back.The endpoint must be driven more than once: the
RESETonly appears when the statement is re-executed from Connector/J's cache. This sample already enables that viauseServerPrepStmts=true&cachePrepStmts=true.Verification
Run locally against TiDB with keploy
05b4eadaand with the #4262 fix:COM_STMT_EXECUTEmocksCOM_STMT_SEND_LONG_DATAmocksCan not read response from serverOn the buggy build the EXECUTEs'
OKs are attributed to theCOM_STMT_RESETmocks and the EXECUTE requests are dropped entirely — exactly the symptom the issue describes.Consumer
The keploy-side PR drives
/api/blob/2048three times from.github/workflows/test_workflow_scripts/java/tidb_stmt_cache/java-linux.shand asserts on the recorded artifact thatCOM_STMT_EXECUTEmocks exist alongside theSEND_LONG_DATAones — record and replay were wrong in the same direction, so a report-status check alone can pass while the trace is missing every EXECUTE.This PR needs to merge first, otherwise the keploy-side guard runs against an endpoint that does not exist yet.