Repository navigation
Fix: Await prepared-statement parameter metadata before execution - #148
Merged
Merged
Conversation
Member
|
That's correct, the getParameterDefinitions() was added just for that purpose... Thanks! |
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.
Problem
With 3.1.1, production connections through a load balancer to database replicas
intermittently fail with:
1835 / HY000: Malformed communication packet1210 / HY000: Incorrect arguments to mysqld_stmt_executeThe same SQL and bindings do not reproduce the errors against a single DB
without a load balancer. Changed delivery timing/socket-read boundaries seems
to be the trigger.
handlePrepare()resolves the statement before all metadata arrives.MysqlConnectionStatement::execute()passes$result->paramsby value, so thequeued processor task retains incomplete definitions even after metadata arrives.
This produces malformed
COM_STMT_EXECUTEpackets.Fix
Await complete definitions using the existing accessor:
Validation
pass afterward (missing/partial/complete definitions and preparation failure).
composer cs-fix,composer cs, and Psalm: pass.XDEBUG_MODE=off: 233 passed, 10 skipped, no failures or errors.developmode triggered a deadlock inMysqlNestedTransactionTest::testNextResultBeforeConsumptionin our setup;with Xdebug off, that test passes both before and after the fix.
in an identical temporary copy; the full suite used a database-bootstrap override.
definitions initially available, payloads were 10/15/18 bytes before the fix;
all correctly become 18 bytes afterward (excluding packet headers).
verifies malformed encoding, not both live-server error codes.
Reproduce the regression
With development dependencies installed, run the new tests without a database:
XDEBUG_MODE=off composer test -- --bootstrap vendor/autoload.php test/MysqlConnectionStatementTest.phpThe tests delay metadata completion via the event loop and check that execution
receives every definition, or propagates preparation failure without execution.