hyperf / hyperf

🚀 A coroutine framework that focuses on hyperspeed and flexibility. Building microservice or middleware with ease.
https://www.hyperf.io
MIT License
6.15k stars 1.19k forks source link

[BUG] kill -15 无法正常关闭服务 #3898

Closed tw2066 closed 2 years ago

tw2066 commented 3 years ago

hyperf 2.2.1 swoole 4.6.7 php8

    'settings' => [
        'enable_coroutine' => true,
        'worker_num' => 3,
        'pid_file' => BASE_PATH . '/runtime/hyperf.pid',
        'open_tcp_nodelay' => true,
        'max_coroutine' => 100000,
        'open_http2_protocol' => true,
        'max_request' => 100000,
    ],

Description:

1.触发了很多Hyperf\Framework\Event\OnWorkerExit handled by Hyperf\Kafka\Listener\AfterWorkerExitListener监听 起码100多次 2.zRangeByScore报错

Steps To Reproduce:

1.找到服务的pid 267 2.kill -15 267 3.触发 Server is shutdown now 4.终端打印

2021-08-02 15:50:33.726 [DEBUG] [NacosDriver::Hyperf\ServiceGovernanceNacos\{closure}] Instance 10.50.3.136:9588 heartbeat successfully, result code:10200
2021-08-02 15:50:38.733 [DEBUG] [NacosDriver::Hyperf\ServiceGovernanceNacos\{closure}] Instance 10.50.3.136:9588 heartbeat successfully, result code:10200
[2021-08-02 15:50:40 #268.3]    INFO    Server is shutdown now
2021-08-02 15:50:40.646 [DEBUG] [EventDispatcher::dump] Event Hyperf\Framework\Event\OnWorkerExit handled by Hyperf\Kafka\Listener\AfterWorkerExitListener listener.

   此处省略大概100行(Hyperf\Kafka\Listener\AfterWorkerExitListener).... 

2021-08-02 15:50:41.496 [DEBUG] [EventDispatcher::dump] Event Hyperf\Framework\Event\OnWorkerExit handled by Hyperf\Kafka\Listener\AfterWorkerExitListener listener.
2021-08-02 15:50:42.999 [DEBUG] [EventDispatcher::dump] Event Hyperf\Framework\Event\OnWorkerExit handled by Hyperf\Kafka\Listener\AfterWorkerExitListener listener.
2021-08-02 15:50:43.000 [DEBUG] [EventDispatcher::dump] Event Hyperf\Framework\Event\OnWorkerExit handled by Hyperf\Kafka\Listener\AfterWorkerExitListener listener.
2021-08-02 15:50:43.000 [DEBUG] [EventDispatcher::dump] Event Hyperf\Framework\Event\OnWorkerExit handled by Hyperf\Kafka\Listener\AfterWorkerExitListener listener.
[2021-08-02 15:50:43 *278.0]    WARNING Worker_reactor_try_to_exit (ERRNO 9012): worker exit timeout, forced termination

===================================================================
 [FATAL ERROR]: all coroutines (count: 1) are asleep - deadlock!
===================================================================

 [Coroutine-3]
--------------------------------------------------------------------
#0  Redis->zRangeByScore() called at [/mnt/d/WWW/hf20/vendor/hyperf/redis/src/RedisConnection.php:76]
#1  Hyperf\Redis\RedisConnection->__call() called at [/mnt/d/WWW/hf20/vendor/hyperf/redis/src/Redis.php:49]
#2  Hyperf\Redis\Redis->__call() called at [/mnt/d/WWW/hf20/vendor/hyperf/redis/src/RedisProxy.php:32]
#3  Hyperf\Redis\RedisProxy->__call() called at [/mnt/d/WWW/hf20/vendor/hyperf/socketio-server/src/Room/RedisAdapter.php:207]
#4  Hyperf\SocketIOServer\Room\RedisAdapter->cleanUpExpiredOnce() called at [/mnt/d/WWW/hf20/vendor/hyperf/socketio-server/src/Room/RedisAdapter.php:199]
#5  Hyperf\SocketIOServer\Room\RedisAdapter->Hyperf\SocketIOServer\Room\{closure}() called at [/mnt/d/WWW/hf20/vendor/hyperf/utils/src/Functions.php:271]
#6  call() called at [/mnt/d/WWW/hf20/vendor/hyperf/utils/src/Coroutine.php:62]

2021-08-02 15:50:43.035 [DEBUG] [EventDispatcher::dump] Event Hyperf\Framework\Event\OnShutdown handled by App\Listener\OnShutdownListener listener.
tw@WIN-RJACNS8A7VM:/mnt/d/WWW/hf20$ composer info | grep kafka
^[[Chyperf/kafka                            v2.2.0     A kafka client for Hyperf
longlang/phpkafka                       v1.1.4     A kafka client. Support php-fpm and Swoole.
huangdijia commented 3 years ago

试试 killall -9 php

tw2066 commented 3 years ago

直接结束了 但是没有触发 OnShutdown 事件

limingxinleo commented 3 years ago

Redis那个应该不用管,那个是正常现象

limingxinleo commented 3 years ago

Kafka那个,应该是进程退出的时候,出现了什么问题,等我们查一查

PandaLIU-1111 commented 2 years ago

@tw2066 可以提供一个最小的复现 demo 吗,我这边试了一下没有复现你的这种场景

tw2066 commented 2 years ago

今天更新了 组件到2.2.8 就没有这样的问题了