-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Description
1. What did you do? If possible, provide a simple script for reproducing the error.
I’m returning connections back to the pool, if exceptions happen. This may happen in the main function or some sub-routine.
class PoolExample
{
protected $pool;
public function main()
{
$this->pool = new PDOPool(…);
$connection = $this->pool->get();
try {
// Do something with $connection
$this->subroutine($connection);
// Do something else
} finally {
$this->pool->put($connection);
}
}
protected function subroutine(PDOProxy $connection)
{
try {
// Do something with connection that throws an exception (e.g. invalid SQL syntax)
} catch (Exception $e) {
$this->pool->put($connection);
throw $e;
}
}
}2. What did you expect to see?
Well, a working application. If I try to put back a connection to the pool, which is already in the pool, this should either be silently ignored or throw a catchable exception/warning.
3. What did you see instead?
The system just crashes and doesn’t respond anymore. The logs show
[FATAL ERROR]: all coroutines (count: 1) are asleep - deadlock!
4. What version of Swoole are you using (show your php --ri swoole)?
swoole
Swoole => enabled
Author => Swoole Team team@swoole.com
Version => 4.7.1
Built => Oct 9 2021 00:21:35
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
spinlock => enabled
rwlock => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
async_redis => enabledDirective => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => On => On
swoole.unixsock_buffer_size => 8388608 => 8388608
5. What is your machine environment used (show your uname -a & php -v & gcc -v) ?
Linux 556ec368b5d0 5.10.47-linuxkit #1 SMP Sat Jul 3 21:51:47 UTC 2021 x86_64 Linux
PHP 8.0.11 (cli) (built: Sep 23 2021 20:15:09) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.11, Copyright (c) Zend Technologies