Skip to content
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

Can not send more queries after 'Not supportted value type' exception #167

Open
yyydevf opened this issue Nov 24, 2022 · 5 comments
Open
Labels

Comments

@yyydevf
Copy link

yyydevf commented Nov 24, 2022

Hello

I have a bug in v 0.5.* and v0.6.*

While we have an invalid type of argument, we haven't drop current state of mysql, look at example, because exception does not catch

<?php


declare(strict_types=1);

require_once 'vendor/autoload.php';

$connection = $factory->createLazyConnection('root:[email protected]:3306/storage');
$connection->query("update table set value = ?", [new stdClass()]) // Invalid type of object
    ->otherwise(function ($e) use ($connection) {
        return $connection->query("select * from table where id = 1")
            ->then(function ($e) {
                echo 1; // thats never happened
            })
            ->otherwise(function ($e) use ($connection) {
                echo 1; // thats too
            });
    });

Look at this method:

protected function nextRequest($isHandshake = false)

And its body (i do not know how to reply multiple lines of code, sorry, so paste my)

protected function nextRequest($isHandshake = false)
    {
        if (!$isHandshake && $this->phase != self::PHASE_HANDSHAKED) {
            return false;
        }

        if ($this->currCommand === null && !$this->executor->isIdle()) {
            $command = $this->executor->dequeue(); 
            $this->currCommand = $command; // current command set here

            if ($command instanceof AuthenticateCommand) {
                $this->phase = self::PHASE_AUTH_SENT;
                $this->sendPacket($command->authenticatePacket($this->scramble, $this->buffer));
            } else {
                $this->seq = 0;
                $this->sendPacket($this->buffer->buildInt1($command->getId()) . $command->getSql()); // Exception occurs here
            }
        }

        return true;
    }

Exception line never catched and just reject:

throw new \InvalidArgumentException(sprintf('Not supportted value type of %s.', $type));

return \React\Promise\reject($e);

So we are cannot send more queries from its connection, cause do not drop $this->currCommand

@yyydevf yyydevf changed the title Can not send more queries afre 'Not supportted value type' error Can not send more queries after 'Not supportted value type' exception Nov 25, 2022
@SimonFrings
Copy link
Contributor

@yyydevf Thanks for reporting this 👍

This indeed sounds like a bug, seems like we need some additional tests for this case to confirm. If this is a bug we then need some code adjustments. We're always happy about PRs, so if you want to take a closer look at this I'm always happy to help 👍

@SimonFrings
Copy link
Contributor

I labeled this ticket as a question for now until we're sure this is a bug.

@pfk84
Copy link

pfk84 commented Jul 10, 2023

I can confirm this is indeed an issue.

@pfk84
Copy link

pfk84 commented Apr 30, 2024

Any news on this issue? Do you need help fixing this? The connection seems to hang until whatever timeout is reached rapidly exhausting connections until max MySQL connections are reached...

@SimonFrings
Copy link
Contributor

@pfk84 Help with this is always appreciated. In order to properly fix this we'd need a test to reproduce this behavior and then make the failing test green by fixing the reported issue. I looked into this before but didn't really found the cause of this. So I guess all I want to say here is: Pull request are welcome 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants