shadowfax icon indicating copy to clipboard operation
shadowfax copied to clipboard

Laravel Admin Csv导出功能易现的 MySQL General error 2014 错误

Open wilbur-yu opened this issue 3 years ago • 5 comments

[2020-08-26 15:31:00] production.ERROR: SQLSTATE[HY000]: General error: 2014 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. (SQL: select * from `points` order by `score` desc, `score` desc limit 100 offset 0) {"exception":"[object] (Illuminate\\Database\\QueryException(code: HY000): SQLSTATE[HY000]: General error: 2014 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. (SQL: select * from `points` order by `score` desc, `score` desc limit 100 offset 0) at /web/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:671)
[previous exception] [object] (Doctrine\\DBAL\\Driver\\PDOException(code: HY000): SQLSTATE[HY000]: General error: 2014 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. at /web/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:66)
[previous exception] [object] (PDOException(code: HY000): SQLSTATE[HY000]: General error: 2014 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. at /web/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:64)
[2020-08-26 15:31:08] production.ERROR: swoole exit {"exception":"[object] (Swoole\\ExitException(code: 0): swoole exit at /web/project/vendor/encore/laravel-admin/src/Grid/Exporters/CsvExporter.php:171)

wilbur-yu avatar Aug 26 '20 07:08 wilbur-yu

我看Laravel Admin导出csv或者excel的方法里面调用了exit,这个兼容不了。当调用exit时,swoole会抛出一个ExitException,就会走Laravel的异常处理逻辑了,这个还真不好处理。

前面的sql报错是因为数据量大吗?你的数据量有多大呢?提供给我模拟测试看看。

huang-yi avatar Aug 26 '20 14:08 huang-yi

嗯, 数据量也不是特别大, 18588条吧. 是两个一对一关联表

wilbur-yu avatar Aug 27 '20 04:08 wilbur-yu

提个实现的意见. 部分功能如果无法兼容. 可以考虑写个转发黑名单. 名单内的api请求. 转发fpm处理. 这样可以最大程度进行适配,

iblues avatar Aug 28 '20 01:08 iblues

@iblues 很好的建议,不过目前还不会计划在Shadowfax里面添加这个功能,可自行使用nginx实现这个功能。

huang-yi avatar Aug 29 '20 05:08 huang-yi

之前也有研究过,写了一个兼容扩展,可以参考试试: https://github.com/hanchikang/laravel-admin-shadowfax

hanchikang avatar Sep 14 '20 08:09 hanchikang