reset primary read replica connections when reseting registry
fix: https://github.com/doctrine/DoctrineBundle/issues/2154
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).
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.
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