-
-
Notifications
You must be signed in to change notification settings - Fork 474
Description
Bug Report
Summary
When using FrankenPHP in Worker mode with a Primary / Read Replica connection. If in a http request we do an write action in database, the connection will switch to primary connection and doctrine will switch back to replica on a new http request.
There is a closed issue in Franken PHP repo php/frankenphp#1444 but IMO adding a $this->connection->ensureConnectedToReplica(); in the start or the end of each request is a workaround not a fix.
As a developer, I expect that, each new HTTP request will reset the connection and we will be on replica. Like when we are not in worker mode.
Current behavior
When cennection switch to primary, it stay connected to Primary on each new HTTP request
Expected behavior
Each new HTTP request will be connected to replica even if previous http request did a write action in database
How to reproduce
- Run a FrankenPHP server in Worker Mode with a Symfony Application.
- Configure a postgresql server with a read replica
- Add 2 route, one with a
SELECTthe other with aINSERTstatement - call the endpoint with the
INSERTstatement - call the endpoint with the
SELECTstatement - look primary postgresql logs, you will see the select statement.