-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix GH-11950: [mysqlnd] Fixed not to set CR_MALFORMED_PACKET to error if CR_SERVER_GONE_ERROR is already set #11951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
PHP 8.0 is out of support, please rebase onto 8.1 |
Thank you. I know that PR. |
c9abe2c
to
a4b83c4
Compare
Thanks, fixed it. |
Are you sure? When I execute your test script on both master and 8.1, I get this:
|
Hmm, this happens no matter how many times I try.
I'll check again to see if I've misconfigured something. |
Although the result has not changed yet, I will describe my operating environment. I are still investigating. https://gist.github.com/SakiTakamachi/866c15ef2e8e333ae526a286b1428fbc |
First of all, it looks like (edit) I made the breakpoints a bit more descriptive and re-ran.
|
@kamil-tekiela 0d922aa This issue is for I think the problem is that |
I still cannot reproduce this issue in my environment. I don't know what I am doing wrong. I would appreciate some step by step instructions. If you really get the error "Error while reading INIT_DB's response packet." then it means something is seriously broken. This warning is defensive programming and we should never get there. So I don't think it's the case of overwritten error, but something more serious. I would appreciate if you could share as much details as possible. I hope we can resolve it together. |
I see. I'll keep investigating to see if I can find any clues.
|
The error php-src/ext/mysqlnd/mysqlnd_wireprotocol.c Line 2581 in 7f1c3bf
This This message is easily printed because php-src/ext/mysqlnd/mysqlnd_wireprotocol.c Line 2570 in 7f1c3bf
php-src/ext/mysqlnd/mysqlnd_wireprotocol.c Line 2471 in 7f1c3bf
|
To reproduce this error, restart the docker mysql container itself. I'm trying to see if it can be reproduced with php and mysql on the host OS without using docker. |
(edit) Oops, I forgot to build the local php. I'll rerun. I have successfully reproduced it on the host OS. repro code
my envMacBook Pro 16-inch, 2019 (intel)
steps
|
PHP 8.2.9 isn't the latest release in PHP 8.2 branch. My fix is included in 8.2.10 |
I forgot to build a fresh PHP on my host OS. It could be reproduced when connecting from PHP in the Docker container to mysql on the host. I'll look into it some more. |
If using php of host OS, this php-src/ext/mysqlnd/mysqlnd_commands.c Line 92 in 7f1c3bf
And in gdb I get the following message: Thread 2 received signal SIGPIPE, Broken pipe
On the other hand, if using php in a docker container, the above php-src/ext/mysqlnd/mysqlnd_commands.c Line 100 in 7f1c3bf
|
That's exactly what my commit (0d922aa) fixed. I guess something must be wrong with your docker setup if compiling PHP 8.1 branch still produces this error. The function returned PASS because the value of Please double check your docker setup. Check what the value of Good job on debugging though. This is a really good skill. |
The docker write buffer results were exactly the same as when I had a normal connection.
After digging this far, I finally got an idea, but isn't this a problem with the specifications of socket communication? |
I think this prediction is probably correct. Perhaps the result was different because it was a combination of php and mysql of the host OS. If the services are in the same environment, the disconnection may be noticed the first time |
Is there any more information you need? |
I am busy with some other stuff at the moment. I will review it soon. I need to spend some more time to check what you are saying. |
Okay, sorry for rushing you. |
IMO the error emitted here: php-src/ext/mysqlnd/mysqlnd_wireprotocol.c Line 2471 in f907a00
is potentially misleading. There's a difference between trying to read the socket and getting EOF and reading in an actually malformed packet. In both cases Looking at mysqlnd it looks there are lots of similar assumptions floating around. |
Yeah, php-src/ext/mysqlnd/mysqlnd_wireprotocol.c Line 2469 in f907a00
And if this results in php-src/ext/mysqlnd/mysqlnd_wireprotocol.c Line 297 in f907a00
Therefore, I changed it to check if an error has already been set when |
Understood. I would bet this could happen in other places too. Rather than fixing your very specific case, could it be solved more generally in My comments re: |
I see, that makes sense. As far as I could see, this was the only place where this could happen, so I was proposing a fix like this. However, in a sense, my modification is like a monkey patch, and it may be wise to fundamentally change the mechanism to solve the problem. |
cfc659a
to
68cdd3f
Compare
68cdd3f
to
1e35957
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to reproduce the issue, and I see how it is caused by an error that was overwritten. This does fix the issue for me.
LGTM.
@nielsdos Ok, can you please merge the PR then? As long as it fixes the issue and doesn't cause any others then let's merge it. |
Thanks for checking and merging! |
This is a PR to solve the issue #11950