在thinkphp8.1环境下,workerman使用Swoole驱动时出现了ab并发报错异常

goug7786

描述

环境:thinkphp8.1 + thinkadmin6 + php8.4 + workerman5.1(Swoole驱动)

Event驱动下正常,但换Swoole驱动就不正常了

Swoole驱动下,使用Apifox接口工具发起请求是正常的,但是使用ab测压工具就会报错,错误如下

测压命令:ab -n 1000 -c100 -p /root/postdata.txt -T application/json http://127.0.0.1:2346/api/index/cash

详细配置:/config/database.php

return [
    // 默认使用的数据库连接配置
    'default'         => env('default_db_type', 'mysql'),
    // 自定义时间查询规则
    'time_query_rule' => [],
    // 自动写入时间戳字段
    'auto_timestamp'  => true,
    // 时间字段取出后的默认时间格式
    'datetime_format' => 'Y-m-d H:i:s',
    // 数据库连接配置信息
    'connections'     => [
        'mysql'  => [
            // 数据库类型
            'type'            => 'mysql',
            // 服务器地址
            'hostname'        => env('mysql.hostname', '127.0.0.1'),
            // 数据库名
            'database'        => env('mysql.database', 'test'),
            // 用户名
            'username'        => env('mysql.username', 'test'),
            // 密码
            'password'        => env('mysql.password', '123456'),
            // 端口
            'hostport'        => env('mysql.hostport', '3306'),
            // 数据库连接参数
            'params'          => [],
            // 数据库编码默认采用 utf8
            'charset'         => env('mysql.charset', 'utf8mb4'),
            // 数据库表前缀
            'prefix'          => env('mysql.prefix', ''),
            // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
            'deploy'          => 0,
            // 数据库读写是否分离 主从式有效
            'rw_separate'     => false,
            // 读写分离后 主服务器数量
            'master_num'      => 1,
            // 指定从服务器序号
            'slave_no'        => '',
            // 检查字段是否存在
            'fields_strict'   => true,
            // 是否需要断线重连
            'break_reconnect' => false,
            // 监听SQL执行日志
            'trigger_sql'     => env('mysql.debug', 'true'),
            // 开启字段类型缓存
            'fields_cache'    => isOnline(),
        ],
        'sqlite' => [
            'charset'     => 'utf8',
            // 数据库类型
            'type'        => 'sqlite',
            // 数据库文件
            'database'    => syspath('database/sqlite.db'),
            // 监听执行日志
            'trigger_sql' => true,
            // 其他参数字段
            'deploy'      => 0,
            'suffix'      => '',
            'prefix'      => '',
            'hostname'    => '',
            'hostport'    => '',
            'username'    => '',
            'password'    => '',
        ],
    ],
];

详细配置:/config/worker.php

$get_cpu_cores = 0; // 获取CPU逻辑核心数
$memory_gb = 0.00;  // 获取物理内存
if (PHP_OS_FAMILY === 'Windows') {
    // Windows
    // CPU逻辑核心数
    $get_cpu_cores = (string)(int)shell_exec('echo %NUMBER_OF_PROCESSORS%');
    // 物理内存
    $output = shell_exec('wmic ComputerSystem get TotalPhysicalMemory');
    $bytes = (int)preg_replace('/\D/', '', $output);
    $memory_gb = (string)round($bytes / (1024 ** 3), 2); // 字节转 GB
} else {
    // Linux
    // CPU逻辑核心数
    $get_cpu_cores = (string)(int)shell_exec('nproc --all');
    // 物理内存
    $meminfo = shell_exec('cat /proc/meminfo');
    if ($meminfo && preg_match('/MemTotal:\s+(\d+)\s+kB/', $meminfo, $matches)) {
        $kb = (int)$matches[1];
        $memory_gb = (string)round($kb / 1024 / 1024, 2); // KB转GB
    }
}
// $num_temp = bcmul($get_cpu_cores, $memory_gb, 2);
// $worker_num = (int)bcdiv($num_temp, "0.256");   // 进程数:CPU 核心数 × 内存 (GB) / 单进程内存占用 (GB)
$worker_num = (int)bcmul($get_cpu_cores, 8, 2); // 进程数:CPU核数的3-8倍

return [
    // 服务监听地址
    'host'     => '127.0.0.1',
    // 服务监听端口
    'port'     => 2346,
    // 套接字上下文选项
    'context'  => [],
    // 高级自定义服务类
    'classes'  => '',
    // 消息请求回调处理
    'callable' => null,
    // 服务进程参数配置
    'worker'   => [
        'name'  => 'ThinkAdmin',
        'count' => $worker_num,    // 进程数:CPU 核心数 × 内存 (GB) / 单进程内存占用 (GB); 或者CPU核数的3-8倍
        'reusePort' => true,
        'eventLoop' => Workerman\Events\Swoole::class,
    ],
];

详细环境

# composer info
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? yes
PHP Deprecated:  think\admin\install\Support::exec(): Implicitly marking parameter $callabel as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/pay/vendor/zoujingli/think-install/src/Support.php on line 132
bacon/bacon-qr-code          2.0.8   BaconQrCode is a QR code generator for PHP.
dasprid/enum                 1.0.6   PHP 7.1 enum implementation
nette/php-generator          4.1.8   🐘 Nette PHP Generator: generates neat PHP code for you. Supports new P...
nette/utils                  4.0.6   🛠  Nette Utils: lightweight utilities for string & array manipulation,...
open-smf/connection-pool     2.0.0   A common connection pool based on Swoole is usually used as the database ...
psr/container                2.0.2   Common Container Interface (PHP FIG PSR-11)
psr/http-message             1.1     Common interface for HTTP messages
psr/log                      3.0.2   Common interface for logging libraries
psr/simple-cache             3.0.0   Common interfaces for simple caching
stechstudio/backoff          1.6     PHP library providing retry functionality with multiple backoff strategie...
swoole/ide-helper            5.1.7   IDE help files for Swoole.
symfony/finder               7.2.2   Finds files and directories via an intuitive fluent interface
symfony/process              7.2.5   Executes commands in sub-processes
topthink/framework           8.1.2   The ThinkPHP Framework.
topthink/think-container     3.0.2   PHP Container & Facade Manager
topthink/think-helper        3.1.11  The ThinkPHP6 Helper Package
topthink/think-migration     3.1.1  
topthink/think-orm           3.0.34  the PHP Database&ORM Framework
topthink/think-swoole        4.1.1   Swoole extend for thinkphp
topthink/think-template      3.0.2   the php template engine
topthink/think-validate      3.0.5   think validate
topthink/think-view          2.0.5   thinkphp template driver
workerman/coroutine          1.1.3   Workerman coroutine
workerman/workerman          5.1.1   An asynchronous event driven PHP framework for easily building fast, scal...
zoujingli/ip2region          2.0.6   Ip2Region for PHP
zoujingli/qrcode             1.0.3   Endroid QrCode for ThinkAdmin
zoujingli/think-install      1.0.49  Plugin Installer for ThinkAdmin
zoujingli/think-library      6.1.86  Library for ThinkAdmin
zoujingli/think-plugs-admin  1.0.71  Admin Plugin for ThinkAdmin
zoujingli/think-plugs-static 1.0.128 Static Files for ThinkAdmin
zoujingli/think-plugs-wechat 1.0.47  WeChat Plugin for ThinkAdmin
zoujingli/think-plugs-worker 1.0.28  Workerman HttpServer for ThinkAdmin
zoujingli/wechat-developer   1.2.74  WeChat and Alipay Platform Development

报错提示:

---------------------------------------------- WORKERMAN -----------------------------------------------
Workerman/5.1.1         PHP/8.4.2 (Jit on)            Linux/6.8.0-40-generic
----------------------------------------------- WORKERS ------------------------------------------------
event-loop  proto       user        worker        listen                   count       state            
swoole      tcp         root        ThinkAdmin    http://127.0.0.1:2346    16           [OK]            
--------------------------------------------------------------------------------------------------------
Press Ctrl+C to stop. Start success.
PHP Fatal error:  Uncaught Swoole\Error: Socket#13 has already been bound to another coroutine#17, reading of the same socket in coroutine#15 at the same time is not allowed in /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php:800
Stack trace:
#0 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php(800): PDO->prepare()
#1 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php(899): think\db\PDOConnection->getPDOStatement()
#2 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php(860): think\db\PDOConnection->queryPDOStatement()
#3 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php(989): think\db\PDOConnection->pdoExecute()
#4 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/BaseQuery.php(1266): think\db\PDOConnection->insert()
#5 /www/wwwroot/pay/app/item/sys.php(33): think\db\BaseQuery->insert()
#6 /www/wwwroot/pay/app/api/controller/Index.php(115): app\item\sys::setResLog()
#7 [internal function]: app\api\controller\Index->cash()
#8 /www/wwwroot/pay/vendor/topthink/think-container/src/Container.php(349): ReflectionMethod->invokeArgs()
#9 /www/wwwroot/pay/vendor/topthink/framework/src/think/route/Dispatch.php(178): think\Container->invokeReflectMethod()
#10 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(59): think\route\Dispatch->{closure:think\route\Dispatch::responseWithMiddlewarePipeline():152}()
#11 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->{closure:think\Pipeline::then():57}()
#12 /www/wwwroot/pay/vendor/topthink/framework/src/think/route/Dispatch.php(152): think\Pipeline->then()
#13 /www/wwwroot/pay/vendor/topthink/framework/src/think/route/dispatch/Controller.php(88): think\route\Dispatch->responseWithMiddlewarePipeline()
#14 /www/wwwroot/pay/vendor/topthink/framework/src/think/route/Dispatch.php(56): think\route\dispatch\Controller->exec()
#15 /www/wwwroot/pay/vendor/topthink/framework/src/think/Route.php(713): think\route\Dispatch->run()
#16 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(59): think\Route->{closure:think\Route::dispatch():712}()
#17 /www/wwwroot/pay/vendor/zoujingli/think-library/src/support/middleware/RbacAccess.php(71): think\Pipeline->{closure:think\Pipeline::then():57}()
#18 [internal function]: think\admin\support\middleware\RbacAccess->handle()
#19 /www/wwwroot/pay/vendor/topthink/framework/src/think/Middleware.php(134): call_user_func()
#20 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->{closure:{closure:think\Middleware::pipeline():128}:129}()
#21 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->{closure:{closure:think\Pipeline::carry():82}:83}()
#22 /www/wwwroot/pay/vendor/topthink/framework/src/think/Route.php(712): think\Pipeline->then()
#23 /www/wwwroot/pay/vendor/topthink/framework/src/think/Http.php(208): think\Route->dispatch()
#24 /www/wwwroot/pay/vendor/topthink/framework/src/think/Http.php(198): think\Http->dispatchToRoute()
#25 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(59): think\Http->{closure:think\Http::runWithRequest():197}()
#26 /www/wwwroot/pay/vendor/zoujingli/think-library/src/support/middleware/MultAccess.php(77): think\Pipeline->{closure:think\Pipeline::then():57}()
#27 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(59): think\admin\support\middleware\MultAccess->{closure:think\admin\support\middleware\MultAccess::handle():76}()
#28 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->{closure:think\Pipeline::then():57}()
#29 /www/wwwroot/pay/vendor/zoujingli/think-library/src/support/middleware/MultAccess.php(76): think\Pipeline->then()
#30 [internal function]: think\admin\support\middleware\MultAccess->handle()
#31 /www/wwwroot/pay/vendor/topthink/framework/src/think/Middleware.php(134): call_user_func()
#32 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->{closure:{closure:think\Middleware::pipeline():128}:129}()
#33 /www/wwwroot/pay/vendor/topthink/framework/src/think/middleware/LoadLangPack.php(53): think\Pipeline->{closure:{closure:think\Pipeline::carry():82}:83}()
#34 [internal function]: think\middleware\LoadLangPack->handle()
#35 /www/wwwroot/pay/vendor/topthink/framework/src/think/Middleware.php(134): call_user_func()
#36 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->{closure:{closure:think\Middleware::pipeline():128}:129}()
#37 /www/wwwroot/pay/vendor/zoujingli/think-library/src/support/middleware/JwtSession.php(101): think\Pipeline->{closure:{closure:think\Pipeline::carry():82}:83}()
#38 [internal function]: think\admin\support\middleware\JwtSession->handle()
#39 /www/wwwroot/pay/vendor/topthink/framework/src/think/Middleware.php(134): call_user_func()
#40 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->{closure:{closure:think\Middleware::pipeline():128}:129}()
#41 /www/wwwroot/pay/vendor/zoujingli/think-library/src/Library.php(140): think\Pipeline->{closure:{closure:think\Pipeline::carry():82}:83}()
#42 [internal function]: think\admin\Library->{closure:think\admin\Library::register():122}()
#43 /www/wwwroot/pay/vendor/topthink/framework/src/think/Middleware.php(134): call_user_func()
#44 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->{closure:{closure:think\Middleware::pipeline():128}:129}()
#45 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->{closure:{closure:think\Pipeline::carry():82}:83}()
#46 /www/wwwroot/pay/vendor/topthink/framework/src/think/Http.php(197): think\Pipeline->then()
#47 /www/wwwroot/pay/vendor/topthink/framework/src/think/Http.php(162): think\Http->runWithRequest()
#48 /www/wwwroot/pay/vendor/zoujingli/think-plugs-worker/src/support/ThinkApp.php(60): think\Http->run()
#49 /www/wwwroot/pay/vendor/zoujingli/think-plugs-worker/src/support/HttpServer.php(126): plugin\worker\support\ThinkApp->worker()
#50 /www/wwwroot/pay/vendor/workerman/workerman/src/Connection/TcpConnection.php(741): plugin\worker\support\HttpServer->onMessage()
#51 /www/wwwroot/pay/vendor/workerman/workerman/src/Events/Swoole.php(288): Workerman\Connection\TcpConnection->baseRead()
#52 [internal function]: Workerman\Events\Swoole->{closure:Workerman\Events\Swoole::safeCall():286}()
#53 {main}
  thrown in /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php on line 800
worker[ThinkAdmin:591410] exit with status 65280
PHP Fatal error:  Uncaught Swoole\Error: Socket#13 has already been bound to another coroutine#19, reading of the same socket in coroutine#21 at the same time is not allowed in /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php:800
Stack trace:
#0 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php(800): PDO->prepare()
#1 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php(899): think\db\PDOConnection->getPDOStatement()
#2 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php(860): think\db\PDOConnection->queryPDOStatement()
#3 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php(989): think\db\PDOConnection->pdoExecute()
#4 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/BaseQuery.php(1266): think\db\PDOConnection->insert()
#5 /www/wwwroot/pay/app/item/sys.php(33): think\db\BaseQuery->insert()
#6 /www/wwwroot/pay/app/api/controller/Index.php(115): app\item\sys::setResLog()
#7 [internal function]: app\api\controller\Index->cash()
#8 /www/wwwroot/pay/vendor/topthink/think-container/src/Container.php(349): ReflectionMethod->invokeArgs()
#9 /www/wwwroot/pay/vendor/topthink/framework/src/think/route/Dispatch.php(178): think\Container->invokeReflectMethod()
#10 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(59): think\route\Dispatch->{closure:think\route\Dispatch::responseWithMiddlewarePipeline():152}()
#11 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->{closure:think\Pipeline::then():57}()
#12 /www/wwwroot/pay/vendor/topthink/framework/src/think/route/Dispatch.php(152): think\Pipeline->then()
#13 /www/wwwroot/pay/vendor/topthink/framework/src/think/route/dispatch/Controller.php(88): think\route\Dispatch->responseWithMiddlewarePipeline()
#14 /www/wwwroot/pay/vendor/topthink/framework/src/think/route/Dispatch.php(56): think\route\dispatch\Controller->exec()
#15 /www/wwwroot/pay/vendor/topthink/framework/src/think/Route.php(713): think\route\Dispatch->run()
#16 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(59): think\Route->{closure:think\Route::dispatch():712}()
#17 /www/wwwroot/pay/vendor/zoujingli/think-library/src/support/middleware/RbacAccess.php(71): think\Pipeline->{closure:think\Pipeline::then():57}()
#18 [internal function]: think\admin\support\middleware\RbacAccess->handle()
#19 /www/wwwroot/pay/vendor/topthink/framework/src/think/Middleware.php(134): call_user_func()
#20 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->{closure:{closure:think\Middleware::pipeline():128}:129}()
#21 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->{closure:{closure:think\Pipeline::carry():82}:83}()
#22 /www/wwwroot/pay/vendor/topthink/framework/src/think/Route.php(712): think\Pipeline->then()
#23 /www/wwwroot/pay/vendor/topthink/framework/src/think/Http.php(208): think\Route->dispatch()
#24 /www/wwwroot/pay/vendor/topthink/framework/src/think/Http.php(198): think\Http->dispatchToRoute()
#25 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(59): think\Http->{closure:think\Http::runWithRequest():197}()
#26 /www/wwwroot/pay/vendor/zoujingli/think-library/src/support/middleware/MultAccess.php(77): think\Pipeline->{closure:think\Pipeline::then():57}()
#27 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(59): think\admin\support\middleware\MultAccess->{closure:think\admin\support\middleware\MultAccess::handle():76}()
#28 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->{closure:think\Pipeline::then():57}()
#29 /www/wwwroot/pay/vendor/zoujingli/think-library/src/support/middleware/MultAccess.php(76): think\Pipeline->then()
#30 [internal function]: think\admin\support\middleware\MultAccess->handle()
#31 /www/wwwroot/pay/vendor/topthink/framework/src/think/Middleware.php(134): call_user_func()
#32 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->{closure:{closure:think\Middleware::pipeline():128}:129}()
#33 /www/wwwroot/pay/vendor/topthink/framework/src/think/middleware/LoadLangPack.php(53): think\Pipeline->{closure:{closure:think\Pipeline::carry():82}:83}()
#34 [internal function]: think\middleware\LoadLangPack->handle()
#35 /www/wwwroot/pay/vendor/topthink/framework/src/think/Middleware.php(134): call_user_func()
#36 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->{closure:{closure:think\Middleware::pipeline():128}:129}()
#37 /www/wwwroot/pay/vendor/zoujingli/think-library/src/support/middleware/JwtSession.php(101): think\Pipeline->{closure:{closure:think\Pipeline::carry():82}:83}()
#38 [internal function]: think\admin\support\middleware\JwtSession->handle()
#39 /www/wwwroot/pay/vendor/topthink/framework/src/think/Middleware.php(134): call_user_func()
#40 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->{closure:{closure:think\Middleware::pipeline():128}:129}()
#41 /www/wwwroot/pay/vendor/zoujingli/think-library/src/Library.php(140): think\Pipeline->{closure:{closure:think\Pipeline::carry():82}:83}()
#42 [internal function]: think\admin\Library->{closure:think\admin\Library::register():122}()
#43 /www/wwwroot/pay/vendor/topthink/framework/src/think/Middleware.php(134): call_user_func()
#44 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->{closure:{closure:think\Middleware::pipeline():128}:129}()
#45 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->{closure:{closure:think\Pipeline::carry():82}:83}()
#46 /www/wwwroot/pay/vendor/topthink/framework/src/think/Http.php(197): think\Pipeline->then()
#47 /www/wwwroot/pay/vendor/topthink/framework/src/think/Http.php(162): think\Http->runWithRequest()
#48 /www/wwwroot/pay/vendor/zoujingli/think-plugs-worker/src/support/ThinkApp.php(60): think\Http->run()
#49 /www/wwwroot/pay/vendor/zoujingli/think-plugs-worker/src/support/HttpServer.php(126): plugin\worker\support\ThinkApp->worker()
#50 /www/wwwroot/pay/vendor/workerman/workerman/src/Connection/TcpConnection.php(741): plugin\worker\support\HttpServer->onMessage()
#51 /www/wwwroot/pay/vendor/workerman/workerman/src/Events/Swoole.php(288): Workerman\Connection\TcpConnection->baseRead()
#52 [internal function]: Workerman\Events\Swoole->{closure:Workerman\Events\Swoole::safeCall():286}()
#53 {main}
  thrown in /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php on line 800
worker[ThinkAdmin:591408] exit with status 65280
PHP Fatal error:  Uncaught Swoole\Error: Socket#13 has already been bound to another coroutine#31, reading of the same socket in coroutine#33 at the same time is not allowed in /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php:800
Stack trace:
#0 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php(800): PDO->prepare()
#1 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php(899): think\db\PDOConnection->getPDOStatement()
#2 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php(860): think\db\PDOConnection->queryPDOStatement()
#3 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php(989): think\db\PDOConnection->pdoExecute()
#4 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/BaseQuery.php(1266): think\db\PDOConnection->insert()
#5 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/BaseQuery.php(1278): think\db\BaseQuery->insert()
#6 /www/wwwroot/pay/app/api/controller/Index.php(102): think\db\BaseQuery->insertGetId()
#7 [internal function]: app\api\controller\Index->cash()
#8 /www/wwwroot/pay/vendor/topthink/think-container/src/Container.php(349): ReflectionMethod->invokeArgs()
#9 /www/wwwroot/pay/vendor/topthink/framework/src/think/route/Dispatch.php(178): think\Container->invokeReflectMethod()
#10 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(59): think\route\Dispatch->{closure:think\route\Dispatch::responseWithMiddlewarePipeline():152}()
#11 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->{closure:think\Pipeline::then():57}()
#12 /www/wwwroot/pay/vendor/topthink/framework/src/think/route/Dispatch.php(152): think\Pipeline->then()
#13 /www/wwwroot/pay/vendor/topthink/framework/src/think/route/dispatch/Controller.php(88): think\route\Dispatch->responseWithMiddlewarePipeline()
#14 /www/wwwroot/pay/vendor/topthink/framework/src/think/route/Dispatch.php(56): think\route\dispatch\Controller->exec()
#15 /www/wwwroot/pay/vendor/topthink/framework/src/think/Route.php(713): think\route\Dispatch->run()
#16 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(59): think\Route->{closure:think\Route::dispatch():712}()
#17 /www/wwwroot/pay/vendor/zoujingli/think-library/src/support/middleware/RbacAccess.php(71): think\Pipeline->{closure:think\Pipeline::then():57}()
#18 [internal function]: think\admin\support\middleware\RbacAccess->handle()
#19 /www/wwwroot/pay/vendor/topthink/framework/src/think/Middleware.php(134): call_user_func()
#20 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->{closure:{closure:think\Middleware::pipeline():128}:129}()
#21 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->{closure:{closure:think\Pipeline::carry():82}:83}()
#22 /www/wwwroot/pay/vendor/topthink/framework/src/think/Route.php(712): think\Pipeline->then()
#23 /www/wwwroot/pay/vendor/topthink/framework/src/think/Http.php(208): think\Route->dispatch()
#24 /www/wwwroot/pay/vendor/topthink/framework/src/think/Http.php(198): think\Http->dispatchToRoute()
#25 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(59): think\Http->{closure:think\Http::runWithRequest():197}()
#26 /www/wwwroot/pay/vendor/zoujingli/think-library/src/support/middleware/MultAccess.php(77): think\Pipeline->{closure:think\Pipeline::then():57}()
#27 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(59): think\admin\support\middleware\MultAccess->{closure:think\admin\support\middleware\MultAccess::handle():76}()
#28 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->{closure:think\Pipeline::then():57}()
#29 /www/wwwroot/pay/vendor/zoujingli/think-library/src/support/middleware/MultAccess.php(76): think\Pipeline->then()
#30 [internal function]: think\admin\support\middleware\MultAccess->handle()
#31 /www/wwwroot/pay/vendor/topthink/framework/src/think/Middleware.php(134): call_user_func()
#32 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->{closure:{closure:think\Middleware::pipeline():128}:129}()
#33 /www/wwwroot/pay/vendor/topthink/framework/src/think/middleware/LoadLangPack.php(53): think\Pipeline->{closure:{closure:think\Pipeline::carry():82}:83}()
#34 [internal function]: think\middleware\LoadLangPack->handle()
#35 /www/wwwroot/pay/vendor/topthink/framework/src/think/Middleware.php(134): call_user_func()
#36 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->{closure:{closure:think\Middleware::pipeline():128}:129}()
#37 /www/wwwroot/pay/vendor/zoujingli/think-library/src/support/middleware/JwtSession.php(101): think\Pipeline->{closure:{closure:think\Pipeline::carry():82}:83}()
#38 [internal function]: think\admin\support\middleware\JwtSession->handle()
#39 /www/wwwroot/pay/vendor/topthink/framework/src/think/Middleware.php(134): call_user_func()
#40 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->{closure:{closure:think\Middleware::pipeline():128}:129}()
#41 /www/wwwroot/pay/vendor/zoujingli/think-library/src/Library.php(140): think\Pipeline->{closure:{closure:think\Pipeline::carry():82}:83}()
#42 [internal function]: think\admin\Library->{closure:think\admin\Library::register():122}()
#43 /www/wwwroot/pay/vendor/topthink/framework/src/think/Middleware.php(134): call_user_func()
#44 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->{closure:{closure:think\Middleware::pipeline():128}:129}()
#45 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->{closure:{closure:think\Pipeline::carry():82}:83}()
#46 /www/wwwroot/pay/vendor/topthink/framework/src/think/Http.php(197): think\Pipeline->then()
#47 /www/wwwroot/pay/vendor/topthink/framework/src/think/Http.php(162): think\Http->runWithRequest()
#48 /www/wwwroot/pay/vendor/zoujingli/think-plugs-worker/src/support/ThinkApp.php(60): think\Http->run()
#49 /www/wwwroot/pay/vendor/zoujingli/think-plugs-worker/src/support/HttpServer.php(126): plugin\worker\support\ThinkApp->worker()
#50 /www/wwwroot/pay/vendor/workerman/workerman/src/Connection/TcpConnection.php(670): plugin\worker\support\HttpServer->onMessage()
#51 /www/wwwroot/pay/vendor/workerman/workerman/src/Events/Swoole.php(288): Workerman\Connection\TcpConnection->baseRead()
#52 [internal function]: Workerman\Events\Swoole->{closure:Workerman\Events\Swoole::safeCall():286}()
#53 {main}
  thrown in /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php on line 800
worker[ThinkAdmin:591396] exit with status 65280
PHP Fatal error:  Uncaught Swoole\Error: Socket#13 has already been bound to another coroutine#45, reading of the same socket in coroutine#43 at the same time is not allowed in /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php:800
Stack trace:
#0 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php(800): PDO->prepare()
#1 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/connector/Mysql.php(68): think\db\PDOConnection->getPDOStatement()
#2 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php(438): think\db\connector\Mysql->getFields()
#3 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php(395): think\db\PDOConnection->getTableFieldsInfo()
#4 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php(360): think\db\PDOConnection->getCachedSchemaInfo()
#5 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php(424): think\db\PDOConnection->getSchemaInfo()
#6 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php(513): think\db\PDOConnection->getTableInfo()
#7 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php(60): think\db\PDOConnection->getFieldsType()
#8 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php(84): think\db\Query->getFieldsType()
#9 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/Builder.php(49): think\db\Query->getFieldsBindType()
#10 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/builder/Mysql.php(129): think\db\Builder->parseData()
#11 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php(986): think\db\builder\Mysql->insert()
#12 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/BaseQuery.php(1266): think\db\PDOConnection->insert()
#13 /www/wwwroot/pay/vendor/topthink/think-orm/src/db/BaseQuery.php(1278): think\db\BaseQuery->insert()
#14 /www/wwwroot/pay/app/api/controller/Index.php(102): think\db\BaseQuery->insertGetId()
#15 [internal function]: app\api\controller\Index->cash()
#16 /www/wwwroot/pay/vendor/topthink/think-container/src/Container.php(349): ReflectionMethod->invokeArgs()
#17 /www/wwwroot/pay/vendor/topthink/framework/src/think/route/Dispatch.php(178): think\Container->invokeReflectMethod()
#18 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(59): think\route\Dispatch->{closure:think\route\Dispatch::responseWithMiddlewarePipeline():152}()
#19 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->{closure:think\Pipeline::then():57}()
#20 /www/wwwroot/pay/vendor/topthink/framework/src/think/route/Dispatch.php(152): think\Pipeline->then()
#21 /www/wwwroot/pay/vendor/topthink/framework/src/think/route/dispatch/Controller.php(88): think\route\Dispatch->responseWithMiddlewarePipeline()
#22 /www/wwwroot/pay/vendor/topthink/framework/src/think/route/Dispatch.php(56): think\route\dispatch\Controller->exec()
#23 /www/wwwroot/pay/vendor/topthink/framework/src/think/Route.php(713): think\route\Dispatch->run()
#24 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(59): think\Route->{closure:think\Route::dispatch():712}()
#25 /www/wwwroot/pay/vendor/zoujingli/think-library/src/support/middleware/RbacAccess.php(71): think\Pipeline->{closure:think\Pipeline::then():57}()
#26 [internal function]: think\admin\support\middleware\RbacAccess->handle()
#27 /www/wwwroot/pay/vendor/topthink/framework/src/think/Middleware.php(134): call_user_func()
#28 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->{closure:{closure:think\Middleware::pipeline():128}:129}()
#29 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->{closure:{closure:think\Pipeline::carry():82}:83}()
#30 /www/wwwroot/pay/vendor/topthink/framework/src/think/Route.php(712): think\Pipeline->then()
#31 /www/wwwroot/pay/vendor/topthink/framework/src/think/Http.php(208): think\Route->dispatch()
#32 /www/wwwroot/pay/vendor/topthink/framework/src/think/Http.php(198): think\Http->dispatchToRoute()
#33 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(59): think\Http->{closure:think\Http::runWithRequest():197}()
#34 /www/wwwroot/pay/vendor/zoujingli/think-library/src/support/middleware/MultAccess.php(77): think\Pipeline->{closure:think\Pipeline::then():57}()
#35 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(59): think\admin\support\middleware\MultAccess->{closure:think\admin\support\middleware\MultAccess::handle():76}()
#36 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->{closure:think\Pipeline::then():57}()
#37 /www/wwwroot/pay/vendor/zoujingli/think-library/src/support/middleware/MultAccess.php(76): think\Pipeline->then()
#38 [internal function]: think\admin\support\middleware\MultAccess->handle()
#39 /www/wwwroot/pay/vendor/topthink/framework/src/think/Middleware.php(134): call_user_func()
#40 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->{closure:{closure:think\Middleware::pipeline():128}:129}()
#41 /www/wwwroot/pay/vendor/topthink/framework/src/think/middleware/LoadLangPack.php(53): think\Pipeline->{closure:{closure:think\Pipeline::carry():82}:83}()
#42 [internal function]: think\middleware\LoadLangPack->handle()
#43 /www/wwwroot/pay/vendor/topthink/framework/src/think/Middleware.php(134): call_user_func()
#44 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->{closure:{closure:think\Middleware::pipeline():128}:129}()
#45 /www/wwwroot/pay/vendor/zoujingli/think-library/src/support/middleware/JwtSession.php(101): think\Pipeline->{closure:{closure:think\Pipeline::carry():82}:83}()
#46 [internal function]: think\admin\support\middleware\JwtSession->handle()
#47 /www/wwwroot/pay/vendor/topthink/framework/src/think/Middleware.php(134): call_user_func()
#48 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->{closure:{closure:think\Middleware::pipeline():128}:129}()
#49 /www/wwwroot/pay/vendor/zoujingli/think-library/src/Library.php(140): think\Pipeline->{closure:{closure:think\Pipeline::carry():82}:83}()
#50 [internal function]: think\admin\Library->{closure:think\admin\Library::register():122}()
#51 /www/wwwroot/pay/vendor/topthink/framework/src/think/Middleware.php(134): call_user_func()
#52 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->{closure:{closure:think\Middleware::pipeline():128}:129}()
#53 /www/wwwroot/pay/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->{closure:{closure:think\Pipeline::carry():82}:83}()
#54 /www/wwwroot/pay/vendor/topthink/framework/src/think/Http.php(197): think\Pipeline->then()
#55 /www/wwwroot/pay/vendor/topthink/framework/src/think/Http.php(162): think\Http->runWithRequest()
#56 /www/wwwroot/pay/vendor/zoujingli/think-plugs-worker/src/support/ThinkApp.php(60): think\Http->run()
#57 /www/wwwroot/pay/vendor/zoujingli/think-plugs-worker/src/support/HttpServer.php(126): plugin\worker\support\ThinkApp->worker()
#58 /www/wwwroot/pay/vendor/workerman/workerman/src/Connection/TcpConnection.php(670): plugin\worker\support\HttpServer->onMessage()
#59 /www/wwwroot/pay/vendor/workerman/workerman/src/Events/Swoole.php(288): Workerman\Connection\TcpConnection->baseRead()
#60 [internal function]: Workerman\Events\Swoole->{closure:Workerman\Events\Swoole::safeCall():286}()
#61 {main}
  thrown in /www/wwwroot/pay/vendor/topthink/think-orm/src/db/PDOConnection.php on line 800
worker[ThinkAdmin:591403] exit with status 65280
134 1 0
1个回答

swoole不允许多个协程同时操作同一个数据库连接,需要使用连接池

×
🔝