Skip to content

5.1.6,使用RedisPool高并发出错 ERROR php_swoole_server_rshutdown() (ERRNO 503) #5630

Closed
@mdys

Description

@mdys

Please answer these questions before submitting your issue.

  1. What did you do? If possible, provide a simple script for reproducing the error.
    server.php
$redis_pool = new RedisPool((new RedisConfig)
		        ->withHost('127.0.0.1')
		        ->withPort(6379)
		        ->withAuth('')
		        ->withDbIndex(0)
		        ->withTimeout(1)
		        ,100000
		  );
$this->redis_pool = $redis_pool;
public function onOpen( $serv, $request ) {
    $redis_pool=$this->redis_pool; 
    $redis = $redis_pool->get(); 
    $redis->get('fd_'.$request->fd);
    $redis_pool->put($redis);
}

在websocket onpen事件时,如果有高并发,大约1s 1000个连接,会有一定几率产生错误,1000个连接失败几十个,产生如下错误:

[2024-12-20 03:53:02 *2291984.253]	
ERROR	php_swoole_server_rshutdown() (ERRNO 503): 
Fatal error: Uncaught RedisException: Connection timed out in @swoole/library/core/Database/RedisPool.php:43
Stack trace:
#0 @swoole/library/core/Database/RedisPool.php(43): Redis->connect()
#1 @swoole/library/core/ConnectionPool.php(88): Swoole\Database\RedisPool->Swoole\Database\{closure}()
#2 @swoole/library/core/ConnectionPool.php(54): Swoole\ConnectionPool->make()
#3 /home/wwwroot/html/server.php(876): Swoole\ConnectionPool->get()
#4 /home/wwwroot/html/server.php(1530): serv_s->onOpen()
#5 [internal function]: serv_s->{closure}()
#6 {main}
  thrown in @swoole/library/core/Database/RedisPool.php on line 43
[2024-12-20 03:53:02 #2291153.0]	WARNING	Server::check_worker_exit_status(): worker(pid=2291967, id=236) abnormal exit, status=0, signal=11
A bug occurred in Swoole-v5.1.6, please report it.
The Swoole developers probably don't know about it,
and unless you report it, chances are it won't be fixed.
You can read How to report a bug doc before submitting any bug reports:
>> https://github.com/swoole/swoole-src/blob/master/.github/ISSUE.md 
Please do not send bug reports in the mailing list or personal letters.
The issue page is also suitable to submit feature requests.

OS: Linux 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64
GCC_VERSION: 8.3.1 20190311 (Red Hat 8.3.1-3)
OPENSSL_VERSION: OpenSSL 1.0.2k-fips  26 Jan 2017
PHP_VERSION : 8.3.8
  1. What did you expect to see?

  2. What did you see instead?

  3. What version of Swoole are you using (show your php --ri swoole)?

Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 5.1.6
Built => Dec  2 2024 14:14:42
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
openssl => OpenSSL 1.0.2k-fips  26 Jan 2017
http2 => enabled
json => enabled
curl-native => enabled
pcre => enabled
c-ares => 1.10.0
zlib => 1.2.7
brotli => E16777225/D16777225
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
mysqlnd => enabled
async_redis => enabled
Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_fiber_mock => Off => Off
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => On => On
swoole.unixsock_buffer_size => 8388608 => 8388608
  1. What is your machine environment used (show your uname -a & php -v & gcc -v) ?
PHP 8.3.8 (cli) (built: Jun 4 2024 14:53:17) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.3.8, Copyright (c) Zend Technologies
with Zend OPcache v8.3.8, Copyright (c), by Zend Technologies`
`COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-8/root/usr --mandir=/opt/rh/devtoolset-8/root/usr/share/man --infodir=/opt/rh/devtoolset-8/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-8.3.1-20190311/obj-x86_64-redhat-linux/isl-install --disable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.3.1 20190311 (Red Hat 8.3.1-3) (GCC)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions