fix(db): Set transaction isolation level for replica connections too

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
Christoph Wurst 2024-04-24 11:42:02 +02:00
parent ffee499f01
commit db0fa54a74
No known key found for this signature in database
GPG Key ID: CC42AC2A7F0E56D8
1 changed files with 3 additions and 5 deletions

View File

@ -39,11 +39,9 @@ class SetTransactionIsolationLevel implements EventSubscriber {
*/
public function postConnect(ConnectionEventArgs $args) {
$connection = $args->getConnection();
if ($connection instanceof PrimaryReadReplicaConnection && $connection->isConnectedToPrimary()) {
$connection->setTransactionIsolation(TransactionIsolationLevel::READ_COMMITTED);
if ($connection->getDatabasePlatform() instanceof MySQLPlatform) {
$connection->executeStatement('SET SESSION AUTOCOMMIT=1');
}
$connection->setTransactionIsolation(TransactionIsolationLevel::READ_COMMITTED);
if ($connection->getDatabasePlatform() instanceof MySQLPlatform) {
$connection->executeStatement('SET SESSION AUTOCOMMIT=1');
}
}