swoole / swoole-src

🚀 Coroutine-based concurrency library for PHP
https://www.swoole.com
Apache License 2.0
18.44k stars 3.16k forks source link

Swoole\Coroutine\Channel->pop() error in Swoft framework #3855

Open 583128870 opened 3 years ago

583128870 commented 3 years ago

Please answer these questions before submitting your issue. Thanks!

  1. What did you do? If possible, provide a simple script for reproducing the error. while (!$this->channel->isEmpty()) { $connection = $this->channel->pop(); } 异常代码:Swoole\Coroutine\Channel->pop();

  2. What did you expect to see?

  3. What did you see instead?

报错内容:Send of 5 bytes failed with errno=32 Broken pipe

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

swoole:4.5.7

  1. What is your machine environment used (show your uname -a & php -v & gcc -v) ? Linux cluster-bk-dep-54996df659-s7cj2 3.10.0-957.21.3.el7.x86_64 #1 SMP Tue Jun 18 16:35:19 UTC 2019 x86_64 GNU/Linux

PHP 7.2.34 (cli) (built: Nov 5 2020 23:33:17) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 8.3.0-6' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 8.3.0 (Debian 8.3.0-6)

huanghantao commented 3 years ago

@583128870 channelpop操作应该是不会触发这个报错。这个报错应该是出现在给tcp连接发送数据的时候,你没有先检查连接是否断开,然后向一个断开的连接发送了数据。

583128870 commented 3 years ago

异常堆栈里报错内容的地址就是这行,这个操作返回的是一个数据库连接对象

huanghantao commented 3 years ago

@583128870 可以提供一个可复现的例子吗?

583128870 commented 3 years ago

这个问题在高版本数据库查询是偶尔出现的,以前低版本swoole 4.4.17没出现过,代码就是swoft2.0.10框架的连接池最新组件代码

583128870 commented 3 years ago

【swoft-connection-pool/AbstractPool.php at v2.0.9 · swoft-cloud/swoft-connection-pool · GitHub】https://github.com/swoft-cloud/swoft-connection-pool/blob/v2.0.9/src/AbstractPool.php

Pool error is Swoft\Connection\Pool\AbstractPool::popByChannel(): Send of 5 bytes failed with errno=32 Broken pipe file=/var/www/swoft/vendor/swoft/connection-pool/src/AbstractPool.php line=277

huanghantao commented 3 years ago

【swoft-connection-pool/AbstractPool.php at v2.0.9 · swoft-cloud/swoft-connection-pool · GitHub】https://github.com/swoft-cloud/swoft-connection-pool/blob/v2.0.9/src/AbstractPool.php

Pool error is Swoft\Connection\Pool\AbstractPool::popByChannel(): Send of 5 bytes failed with errno=32 Broken pipe file=/var/www/swoft/vendor/swoft/connection-pool/src/AbstractPool.php line=277

能否提供一个可以复现出错误的仓库,然后我可以拿下来直接跑。

twose commented 3 years ago

应该是把fwrite操作的notice转换成了ErrorException后特殊处理的结果, 真正的错误堆栈并不在此处 出现这个错误和代码质量有关(不管是你的还是你所使用的代码库), 没有在IO操作出错时立即捕获处理, 导致了错误上浮

583128870 commented 3 years ago

【swoft-connection-pool/AbstractPool.php at v2.0.9 · swoft-cloud/swoft-connection-pool · GitHub】https://github.com/swoft-cloud/swoft-connection-pool/blob/v2.0.9/src/AbstractPool.php Pool error is Swoft\Connection\Pool\AbstractPool::popByChannel(): Send of 5 bytes failed with errno=32 Broken pipe file=/var/www/swoft/vendor/swoft/connection-pool/src/AbstractPool.php line=277

能否提供一个可以复现出错误的仓库,然后我可以拿下来直接跑。

https://github.com/swoft-cloud/swoft/archive/v2.0.9.zip 用4.5.7版本swoole

583128870 commented 3 years ago

应该是把fwrite操作的notice转换成了ErrorException后特殊处理的结果, 真正的错误堆栈并不在此处 出现这个错误和代码质量有关(不管是你的还是你所使用的代码库), 没有在IO操作出错时立即捕获处理, 导致了错误上浮

现在swoft那边官方基本停更了 我写了10多个服务了 说换框架也是不可能的了 被架起了。。。