phoenix icon indicating copy to clipboard operation
phoenix copied to clipboard

reset primary read replica connections when reseting registry

Open sad270 opened this issue 4 weeks ago • 3 comments

fix: https://github.com/doctrine/DoctrineBundle/issues/2154

sad270 avatar Dec 03 '25 17:12 sad270

Closing the connection is better than forcing to connect to the replica. If the next request starts with something that needs to use the primary, it will avoid connecting for nothing (same if the next request does not use the DB at all btw).

stof avatar Dec 03 '25 17:12 stof

As discussed in the issue, this requires being careful with the case of messenger consumers using the doctrine transport. The transport will not like a connection getting closed between message as the transport has a longer lifecycle.

stof avatar Dec 03 '25 17:12 stof

There is a --no-reset option on symfony messenger, if we don't want to reset, but the option will not reset all the symfony resetable services. 🤔

Maybe in the configuration we should add a "close_on_reset" configuration (or something like). If it is true, we close the connection on kernel reset. And for the backward compatibility we set a default value to false

sad270 avatar Dec 03 '25 17:12 sad270