You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Two database connections and missing transaction isolation level for read operations #45003
so it's the Doctrine primary/replica connection class that switches to the primary once we start a transaction. The class doesn't factor in that we only have primary and no replica and still opens a separate connection.
We set the primary parameters as the first replica if there is no replica config. Doctrine requires this for the Primary/Replica class, else it throws Uncaught InvalidArgumentException: You have to configure at least one replica. in nextcloud/3rdparty/doctrine/dbal/src/Connections/PrimaryReadReplicaConnection.php:117.
I think the best fix would be to only subclass PrimaryReadReplicaConnection when db replicas are actually available and use the simple Doctrine Connection instead.
Both of the above have the same underlying cause. #45257 is particularly nasty since it not only doesn't copy the source database, but then it clears out the (wrong) entire database schema (!).
We need to at a minimum clean up the parameter value merging for #45257 (or whatever is the appropriate approach with the new replica stuff now being in mainline). Ideally before next maintenance release (which admittedly is cutting it close and I'm not offering up a fix since I haven't had the time to look deep enough at that area of code so far and doubt I'll have the time to do in the next day or so).
Activity
ChristophWurst commentedon Apr 24, 2024
Stack traces
so it's the Doctrine primary/replica connection class that switches to the primary once we start a transaction. The class doesn't factor in that we only have primary and no replica and still opens a separate connection.
We set the primary parameters as the first replica if there is no replica config. Doctrine requires this for the Primary/Replica class, else it throws
Uncaught InvalidArgumentException: You have to configure at least one replica. in nextcloud/3rdparty/doctrine/dbal/src/Connections/PrimaryReadReplicaConnection.php:117.ChristophWurst commentedon Apr 24, 2024
I think the best fix would be to only subclass PrimaryReadReplicaConnection when db replicas are actually available and use the simple Doctrine Connection instead.
kesselb commentedon Apr 24, 2024
Good finding 👍
joshtrichards commentedon May 16, 2024
We've got some other bugs in this area of code too:
occ db:convert-typebroken sincePrimaryReadReplicaConnectionsupport added #45257Both of the above have the same underlying cause. #45257 is particularly nasty since it not only doesn't copy the source database, but then it clears out the (wrong) entire database schema (!).
We need to at a minimum clean up the parameter value merging for #45257 (or whatever is the appropriate approach with the new replica stuff now being in mainline). Ideally before next maintenance release (which admittedly is cutting it close and I'm not offering up a fix since I haven't had the time to look deep enough at that area of code so far and doubt I'll have the time to do in the next day or so).