swoole / swoole-src

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

php-swoole 6.0.0 is leading to issues with PDO connections to postgres #5386

Closed reubenfirmin closed 4 months ago

reubenfirmin commented 5 months ago

Please answer these questions before submitting your issue.

  1. What did you do? If possible, provide a simple script for reproducing the error.

Please see https://stackoverflow.com/questions/78669556/possible-bug-with-php-pdo-and-with-postgresql - this issue is happening for multiple teams. (We found this thread after this started happening to us yesterday).

  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)?

6.0.0 - we appear to have picked this up along with security patches in PHP 8.2.20 / Ubuntu 20.04.

  1. What is your machine environment used (show your uname -a & php -v & gcc -v) ?

Linux e7843275b2ee78 5.15.98-fly #gac12cf665d SMP Thu Jun 20 16:59:12 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

PHP 8.2.20 (cli) (built: Jun 8 2024 21:37:34) (NTS) Copyright (c) The PHP Group Zend Engine v4.2.20, Copyright (c) Zend Technologies with Zend OPcache v8.2.20, Copyright (c), by Zend Technologies

jingjingxyk commented 4 months ago

reference :

  1. https://github.com/Homebrew/homebrew-core/issues/155651
  2. https://github.com/postgres/postgres/commit/c82207a548db47623a2bfa2447babdaa630302b9
  3. https://www.postgresql.org/message-id/CXA1532Q80DK.81UOGP3O5AP6%40neon.tech
  4. https://github.com/Homebrew/homebrew-core/issues/155651#issuecomment-1828251512
pixelart7 commented 4 months ago

Just wanted to add that if Swoole 6.0.0 has unexpectedly appeared in your Docker image, it might be due to the popular apt package repository (deb.sury.org) updating the php-swoole package to 6.0.0. I've opened an issue there to address this: https://github.com/oerdnj/deb.sury.org/issues/2152.

As recommended by a StackOverflow user (https://stackoverflow.com/a/78675991/2560112), removing or downgrading Swoole when possible might help resolve the issue.

cworreschk commented 4 months ago

I have the same issues with PHP 8.3.8, but with Swoole 5.1.3. The only thing they have in common is that PHP 8.3.8 was also built on July 8 🤔

If I deactivate Swoole, everything works.

PDOException: SQLSTATE[08006] [7] could not send SSL negotiation packet: Resource temporarily unavailable
PHP 8.3.8 (cli) (built: Jun  8 2024 21:34:22) (NTS)
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
ohmydevops commented 4 months ago

We had the same problem. We disabled swoole extension. But we need to downgrade to 5.1.1 for permanent fix.

cworreschk commented 4 months ago

Maybe the Kernel optimization Synchronize PDO operation code across different versions of PHP for 6.0 and 5.3.1 is the reason for the PDO problem. @NathanFreeman

NathanFreeman commented 4 months ago

Perhaps it is related to the SSL changes in PHP versions above 8.2 that I have not synchronized with Swoole. I need to take some time to look into this.

NathanFreeman commented 4 months ago

Do you have SSL mode enabled in your PDO constructor?

yoyoyeahyoyo commented 4 months ago

@NathanFreeman Running $pdo = new PDO($dsn, null, null, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]); Errors: With sslmode 'disable' SQLSTATE[08006] [7] could not send startup packet: Resource temporarily unavailable With sslmode 'require' SQLSTATE[08006] [7] could not send SSL negotiation packet: Resource temporarily unavailable And it works fine with a localhost/127.0.0.1 connection.

NathanFreeman commented 4 months ago

@yoyoyeahyoyo @reubenfirmin Does this issue occur when PostgreSQL, PHP, and Swoole are not on the same server?

yoyoyeahyoyo commented 4 months ago

@yoyoyeahyoyo @reubenfirmin Does this issue occur when PostgreSQL, PHP, and Swoole are not on the same server?

Not sure what you mean. It works fine when trying to connect to a local postgres server, but anything outside of localhost instantly fails. The main servers have php and swoole and postgresql client installed. The php ini configuration for swoole: swoole Author => Swoole Team team@swoole.com swoole.display_errors => On => On swoole.enable_coroutine => On => On swoole.enable_fiber_mock => Off => Off swoole.enable_library => On => On swoole.enable_preemptive_scheduler => Off => Off swoole.unixsock_buffer_size => 8388608 => 8388608 swoole.use_shortname => On => On

I was able to reproduce the error by setting up an ubuntu virtual box instance, installing postgres with pdo, and then installing swoole from ppa:ondrej.

NathanFreeman commented 4 months ago

fixed by https://github.com/swoole/swoole-src/pull/5396