Closed samuelexyz closed 6 months ago
Thank you for reporting the issue and including a debug log from the driver. From it, I can see two connection attempts (both starting with the "Connection String [...]" line. The first one abruptly ends while encoding a document, but the second attempt starts right after that, so I assume the server was still alive. This second attempt continues further, and then abruptly stops when creating the TLS stream. Can you confirm that the time of that last log entry is consistent with when the php-fpm process crashes?
Also, it would be helpful if you could try to reproduce it in the command-line. I ran a quick test with an Atlas cluster on my M1 Pro but couldn't reproduce a crash.
Of course this is the test code:
<?php
require __DIR__ . '/vendor/autoload.php';
use MongoDB\Client;
use MongoDB\Driver\ServerApi;
ini_set('mongodb.debug', '1');
$uri ="mongodb+srv://<url>/?retryWrites=true&w=majority;";
// Specify Stable API version 1
$apiVersion = new ServerApi(ServerApi::V1);
// Create a new client and connect to the server
$client = new MongoDB\Client($uri, [], ['serverApi' => $apiVersion]);
try {
// Send a ping to confirm a successful connection
$client->selectDatabase('admin')->command(['ping' => 1]);
echo "Pinged your deployment. You successfully connected to MongoDB!\n";
} catch (Exception $e) {
printf($e->getMessage());
}
?>
FROM COMMAND LINE:
commandline.log
IT'S WORKING
FROM WEB:
CREATE TWO LOGS
web1.log
AND THIS ONE
web2.log
php error log :
2023/08/22 15:18:34 [error] 32206#0: *1 kevent() reported about an closed connection (54: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8083"
2023/08/22 15:18:34 [error] 32206#0: *1 kevent() reported about an closed connection (54: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8083", referrer: "http://localhost:8083/index.php"
2023/08/22 15:18:35 [error] 32206#0: *1 kevent() reported about an closed connection (54: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8083"
2023/08/22 15:18:35 [error] 32206#0: *1 kevent() reported about an closed connection (54: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8083", referrer: "http://localhost:8083/index.php"
2023/08/22 15:18:37 [error] 32206#0: *7 kevent() reported about an closed connection (54: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8083"
2023/08/22 15:18:38 [error] 32206#0: *7 kevent() reported about an closed connection (54: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8083", referrer: "http://localhost:8083/"
2023/08/22 15:22:14 [error] 32206#0: *11 kevent() reported about an closed connection (54: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8083"
2023/08/22 15:22:14 [error] 32206#0: *11 kevent() reported about an closed connection (54: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8083", referrer: "http://localhost:8083/"
2023/08/22 15:23:05 [error] 32206#0: *19 kevent() reported about an closed connection (54: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8083"
2023/08/22 15:23:06 [error] 32206#0: *19 kevent() reported about an closed connection (54: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8083", referrer: "http://localhost:8083/"
2023/08/22 15:23:13 [error] 32206#0: *23 kevent() reported about an closed connection (54: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8083"
2023/08/22 15:23:13 [error] 32206#0: *23 kevent() reported about an closed connection (54: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8083", referrer: "http://localhost:8083/"
2023/08/22 15:23:46 [error] 32206#0: *27 kevent() reported about an closed connection (54: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8083"
2023/08/22 15:23:47 [error] 32206#0: *27 kevent() reported about an closed connection (54: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8083", referrer: "http://localhost:8083/"
PHP FPM LOG
[22-Aug-2023 15:17:37] WARNING: [pool www] child 31673 exited on signal 11 (SIGSEGV) after 28.652821 seconds from start
[22-Aug-2023 15:17:37] NOTICE: [pool www] child 31901 started
[22-Aug-2023 15:17:37] WARNING: [pool www] child 31674 exited on signal 11 (SIGSEGV) after 28.955554 seconds from start
[22-Aug-2023 15:17:37] NOTICE: [pool www] child 31902 started
[22-Aug-2023 15:17:39] WARNING: [pool www] child 31901 exited on signal 11 (SIGSEGV) after 2.173381 seconds from start
[22-Aug-2023 15:17:39] NOTICE: [pool www] child 31906 started
[22-Aug-2023 15:17:39] WARNING: [pool www] child 31902 exited on signal 11 (SIGSEGV) after 2.000508 seconds from start
[22-Aug-2023 15:17:39] NOTICE: [pool www] child 31907 started
[22-Aug-2023 15:17:46] WARNING: [pool www] child 31906 exited on signal 11 (SIGSEGV) after 6.970074 seconds from start
[22-Aug-2023 15:17:46] NOTICE: [pool www] child 31919 started
[22-Aug-2023 15:17:46] WARNING: [pool www] child 31907 exited on signal 11 (SIGSEGV) after 6.955088 seconds from start
[22-Aug-2023 15:17:46] NOTICE: [pool www] child 31920 started
[22-Aug-2023 15:18:34] WARNING: [pool www] child 31919 exited on signal 11 (SIGSEGV) after 47.763101 seconds from start
[22-Aug-2023 15:18:34] NOTICE: [pool www] child 32371 started
[22-Aug-2023 15:18:34] WARNING: [pool www] child 31920 exited on signal 11 (SIGSEGV) after 47.779048 seconds from start
[22-Aug-2023 15:18:34] NOTICE: [pool www] child 32374 started
[22-Aug-2023 15:18:35] WARNING: [pool www] child 32371 exited on signal 11 (SIGSEGV) after 0.979081 seconds from start
[22-Aug-2023 15:18:35] NOTICE: [pool www] child 32376 started
[22-Aug-2023 15:18:35] WARNING: [pool www] child 32374 exited on signal 11 (SIGSEGV) after 0.980579 seconds from start
[22-Aug-2023 15:18:35] NOTICE: [pool www] child 32377 started
[22-Aug-2023 15:18:37] WARNING: [pool www] child 32376 exited on signal 11 (SIGSEGV) after 2.492545 seconds from start
[22-Aug-2023 15:18:37] NOTICE: [pool www] child 32380 started
[22-Aug-2023 15:18:38] WARNING: [pool www] child 32377 exited on signal 11 (SIGSEGV) after 2.481370 seconds from start
[22-Aug-2023 15:18:38] NOTICE: [pool www] child 32381 started
[22-Aug-2023 15:22:14] WARNING: [pool www] child 32380 exited on signal 11 (SIGSEGV) after 216.656886 seconds from start
[22-Aug-2023 15:22:14] NOTICE: [pool www] child 32736 started
[22-Aug-2023 15:22:14] WARNING: [pool www] child 32381 exited on signal 11 (SIGSEGV) after 216.660919 seconds from start
[22-Aug-2023 15:22:14] NOTICE: [pool www] child 32738 started
[22-Aug-2023 15:23:05] WARNING: [pool www] child 32736 exited on signal 11 (SIGSEGV) after 51.378758 seconds from start
[22-Aug-2023 15:23:05] NOTICE: [pool www] child 32907 started
[22-Aug-2023 15:23:06] WARNING: [pool www] child 32738 exited on signal 11 (SIGSEGV) after 51.418109 seconds from start
[22-Aug-2023 15:23:06] NOTICE: [pool www] child 32910 started
[22-Aug-2023 15:23:13] WARNING: [pool www] child 32907 exited on signal 11 (SIGSEGV) after 7.557748 seconds from start
[22-Aug-2023 15:23:13] NOTICE: [pool www] child 32924 started
[22-Aug-2023 15:23:13] WARNING: [pool www] child 32910 exited on signal 11 (SIGSEGV) after 7.534901 seconds from start
[22-Aug-2023 15:23:13] NOTICE: [pool www] child 32925 started
[22-Aug-2023 15:23:46] WARNING: [pool www] child 32924 exited on signal 11 (SIGSEGV) after 33.374329 seconds from start
[22-Aug-2023 15:23:46] NOTICE: [pool www] child 32987 started
[22-Aug-2023 15:23:47] WARNING: [pool www] child 32925 exited on signal 11 (SIGSEGV) after 33.375672 seconds from start
[22-Aug-2023 15:23:47] NOTICE: [pool www] child 32990 started
if you need anything else just ask me
Hi @samuelexyz, sorry for the lack of reply. I managed to reproduce the issue on my machine and have created PHPC-2280 to track this internally. I'm still investigating why the crash happens, as it is somewhere within system libraries and only triggered when connecting through FPM, but not through the CLI SAPI.
Hi @alcaeus Thank you i will follow PHPC-2280
Hi @samuelexyz, the segmentation fault happens due to the driver being compiled with Secure Transport as SSL library but php-fpm being compiled with OpenSSL. Compiling the driver using OpenSSL fixes the issue. Please note that until we get to PHPC-1017, specifying these options when running pecl install
is impossible, so you'll have to configure the driver manually. Instructions for this can be found in the installation docs. Please note that due to an issue with homebrew (which I haven't been able to work around; see https://github.com/mongodb/mongo-php-driver/issues/1405), you also need to specify the homebrew include directory using CFLAGS
. I used the following configure
call in my tests:
CFLAGS=-I/opt/homebrew/include ./configure --enable-mongodb-developer-flags --with-mongodb-ssl=openssl
I've created https://github.com/mongodb/mongo-php-driver/pull/1463, which targets the v1.16 branch and will be released in an upcoming patch release. With the steps above, you should be able to work around the issue in the meantime; the changes merely change the detection mechanism to prefer OpenSSL over Secure Transport.
Just a minor update: we're releasing the fix in the 1.17 version of the driver. After consideration, we decided that this was too big a change for a 1.16 patch release. I expect 1.17 to be released in the near future, but in the meantime you can use the instructions above to work around the issue.
Closing as this has been released in 1.17.0.
Bug Report
When I try to connect no exception is raised but the php-fpm job is closed and I have a return status of 502 Bad Gateway
Environment
phpinfo()
Test Script
Expected and Actual Behavior
Expect to connect and query without error 502
Debug Log