swoft-cloud / swoft

🚀 PHP Microservice Full Coroutine Framework
https://swoft.org
Apache License 2.0
5.58k stars 786 forks source link

Uncaught Swoole\Error: Socket#41 has already been bound to another coroutine#83028, reading of the same socket in coroutine#83032 at the same time is not allowed in /var/www/swoft/vendor/swoft/redis/src/Connection/Connection.php:266 #1455

Open zuobee opened 2 years ago

zuobee commented 2 years ago
Q A
Bug report? yes
Feature request? yes/no
Swoft version 2.0.11 (by php bin/swoft -V)
Swoole version 4.8.3 (by php --ri swoole)
PHP version 7.2.34(by php -v)
Runtime environment CentOS 7

Describe the bug php error log

^[[15-Dec-2021 11:45:45 Asia/Shanghai] PHP Fatal error:  Uncaught Swoole\Error: Socket#40 has already been bound to another coroutine#1485, reading of the same socket in coroutine#1484 at the same time is not allowed in /var/www/swoft/vendor/swoft/redis/src/Connection/Connection.php:266
Stack trace:
#0 /var/www/swoft/vendor/swoft/redis/src/Connection/Connection.php(266): Redis->sismember('user:total_logi...', '2202017')
#1 /var/www/swoft/vendor/swoft/redis/src/Connection/Connection.php(545): Swoft\Redis\Connection\Connection->command('sIsMember', Array)
#2 /var/www/swoft/vendor/swoft/redis/src/Redis.php(209): Swoft\Redis\Connection\Connection->__call('sIsMember', Array)
#3 /var/www/swoft/app/Model/Logic/UserHandleLogic.php(40): Swoft\Redis\Redis::__callStatic('sIsMember', Array)
#4 /var/www/swoft/app/Http/Controller/UserController.php(155): App\Model\Logic\UserHandleLogic->setTotalCache(2202017, 'login')
#5 /var/www/swoft/vendor/swoft/aop/src/Concern/AopTrait.php(69): App\Http\Controller\UserController->getUserInfo(Object(Swoft\Http\Message\Request))
#6 /var/www/sw in /var/www/swoft/vendor/swoft/redis/src/Connection/Connection.php on line 266

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Details

Describe what you are trying to achieve and what goes wrong.

    'redis' => [
        'class' => RedisDb::class,
        'host' => env('REDIS_HOST', '127.0.0.1'),
        'port' => env('REDIS_PORT', 6379),
        'database' => env('REDIS_DB', 0),
        'password' => env('REDIS_AUTH', ''),
        'option' => [
            'prefix' => 'buzhi:'
        ]
    ],
    'redis.pool' => [
        'class' => \Swoft\Redis\Pool::class,
        'redisDb' => \bean('redis'),
        'minActive' => 10,
        'maxActive' => 200,
        'maxWait' => 100,
        'maxWaitTime' => 60,
        'maxIdleTime' => 60,
    ],

    // 缓存适配器配置
    Cache::ADAPTER => [
        'class' => \App\Common\RedisAdapter::class,
        'prefix' => '',//如果redis 已经有前缀不能再加前缀,否则无法删除缓存
        'redis' => bean('redis.pool'),
        'serializer' => bean(Cache::SERIALIZER),
        // savePath for file cache adapter
        'savePath' => alias('@runtime/caches'),
        // dataFile for swoole table cache adapter
        // 'dataFile'   => alias('@runtime/caches/cache.data'),
    ],

Provide minimal script to reproduce the issue

// paste code
zuobee commented 2 years ago

as the same time [2021-12-15 11:45:46 $18.0] WARNING Server::check_worker_exit_status(): worker(pid=122, id=3) abnormal exit, status=255, signal=0