Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FrankenPHP + Postgres: no connection to the server #438

Closed
darkweak opened this issue Dec 24, 2023 · 8 comments
Closed

FrankenPHP + Postgres: no connection to the server #438

darkweak opened this issue Dec 24, 2023 · 8 comments

Comments

@darkweak
Copy link

Hello,
I experiencing some stuff using FrankenPHP but I'm facing an issue that causes Symfony throw a critical error.

Stack:

  • API Platform base
  • Postgresql (tried with 15 and 14)
  • FrankenPHP
  • Swarm cluster (docker container based on alpine)
{
    "channel": "request",
    "context": {
        "exception": {
            "class": "Doctrine\\DBAL\\Exception\\DriverException",
            "code": 7,
            "file": "/app/vendor/doctrine/dbal/src/Driver/API/PostgreSQL/ExceptionConverter.php:87",
            "message": "An exception occurred while executing a query: SQLSTATE[HY000]: General error: 7 no connection to the server",
            "previous": {
                "class": "Doctrine\\DBAL\\Driver\\PDO\\Exception",
                "code": 7,
                "file": "/app/vendor/doctrine/dbal/src/Driver/PDO/Exception.php:28",
                "message": "SQLSTATE[HY000]: General error: 7 no connection to the server",
                "previous": {
                    "class": "PDOException",
                    "code": 0,
                    "file": "/app/vendor/doctrine/dbal/src/Driver/PDO/Statement.php:130",
                    "message": "SQLSTATE[HY000]: General error: 7 no connection to the server"
                }
            }
        }
    },
    "datetime": "2023-12-24T12:46:50.768750+00:00",
    "extra": {},
    "level": 500,
    "level_name": "CRITICAL",
    "message": "Uncaught PHP Exception Doctrine\\DBAL\\Exception\\DriverException: \"An exception occurred while executing a query: SQLSTATE[HY000]: General error: 7 no connection to the server\" at /app/vendor/doctrine/dbal/src/Driver/API/PostgreSQL/ExceptionConverter.php line 87"
}

The error is thrown after about 10-15 minutes running.
Using directly caddy without FrankenPHP works well but I can't explain it because if I go on the container and type bin/console do:q:sql "SELECT * FROM table" it gets the results from db without any issues.
Any ideas about that ?

@dunglas
Copy link
Owner

dunglas commented Dec 24, 2023

Hi,

This is likely a duplicate of #290.

This is being fixed in Symfony: symfony/symfony#51661

See #243 for workarounds.

@darkweak
Copy link
Author

I probably missed something (the "workaround") but it still doesn't work with the APP_RUNTIME_MODE (from symfony/symfony#52079) 🤷‍♂️

@dunglas
Copy link
Owner

dunglas commented Dec 26, 2023

This mode is a first step but isn't enough. You must backport the RoadRunner patch. Another alternative seems to be to install the ProxyManager bridge.

@lermontex
Copy link

lermontex commented Feb 13, 2024

Got the same issue today after running FranketPHP 1.1.0 + Symfony 7.0.3 for a few days (Docker Swarm), however I'm not using "worker mode". The error disappeared only after restarting FranketPHP

@DennisdeBest
Copy link

Using FrankenPHP 1.1.0 and Symfony 7.0.3 I get

Uncaught PHP Exception Doctrine\DBAL\Exception\ConnectionLost: "An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away" at ExceptionConverter.php line 104 {"exception":"[object] (Doctrine\\DBAL\\Exception\\ConnectionLost(code: 2006): An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away at /app/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php:104)\n[previous exception] [object] (Doctrine\\DBAL\\Driver\\PDO\\Exception(code: 2006): SQLSTATE[HY000]: General error: 2006 MySQL server has gone away at /app/vendor/doctrine/dbal/src/Driver/PDO/Exception.php:28)\n[previous exception] [object] (PDOException(code: HY000): SQLSTATE[HY000]: General error: 2006 MySQL server has gone away at /app/vendor/doctrine/dbal/src/Driver/PDO/Connection.php:71)"}

I get the error on my staging server where it is running in worker mode, This is the worker.Caddyfile

worker {
	file ./public/index.php
	env APP_RUNTIME Runtime\FrankenPhpSymfony\Runtime
}

And the production part of the Dockerfile

# Prod FrankenPHP image
FROM frankenphp_base AS frankenphp_prod

ENV APP_ENV=prod
ENV FRANKENPHP_CONFIG="import worker.Caddyfile"

RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

COPY --from=build_node ./app ./

COPY --link docker/php/conf.d/app.prod.ini $PHP_INI_DIR/conf.d/
COPY --link docker/php/worker.Caddyfile /etc/caddy/worker.Caddyfile

It is trying to connect to a MariaDB10.4 Database.

@dunglas
Copy link
Owner

dunglas commented Feb 25, 2024

@DennisdeBest
Copy link

@DennisdeBest see symfony/symfony#53214

Thanks I'll keep an eye on that

@dunglas
Copy link
Owner

dunglas commented Apr 25, 2024

Fixed by symfony/symfony#53214.

@dunglas dunglas closed this as completed Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants