swoole / library

📚 Swoole Library
https://wiki.swoole.com/#/library
Apache License 2.0
232 stars 59 forks source link

Cannot execute queries while other unbuffered queries are active. #149

Closed videni closed 1 year ago

videni commented 2 years ago

Error stack

Uncaught PDOException: Cannot execute queries while other unbuffered queries are active.  Consider using PDOStatement::fetchAll().  Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in @swoole-src/library/core/Database/PDOStatementProxy.php:64
Stack trace:
#0 /acme/vendor/laravel/framework/src/Illuminate/Database/Connection.php(335): Swoole\Database\PDOStatementProxy->__call('execute', Array)
#1 /acme/vendor/laravel/framework/src/Illuminate/Database/Connection.php(677): Illuminate\Database\Connection->Illuminate\Database\{closure}('select `order_i...', Array)
#3 /acme/vendor/laravel/framework/src/Illuminate/Database/Connection.php(340): Illuminate\Database\Connection->run('select `order_i...', Array, Object(Closure))

What I tried

  1. change to FetchAll , not working

  2. Set atrribute MYSQL_ATTR_USE_BUFFERED_QUERY to true for statement, not working

  3. Close cursor as this cannot-execute-queries-while-other-unbuffered-queries suggests. not working

twose commented 1 year ago

Are you using the same PDO client in different coroutines at the same time?

matyhtf commented 1 year ago

This error means that calls the query method, but before the query returns a complete data set, a new query is initiated using the database connection. MySQL does not allow a new query to be issued without obtaining the full result set.

You should check your code, if there is a new query using this connection every time fetch is called?