[2.10] Unable to persist entites while using PrimaryReadReplicaConnection #6857

Closed
opened 2026-01-22 15:40:08 +01:00 by admin · 6 comments
Owner

Originally created by @lp-contentplus on GitHub (Oct 8, 2021).

Issue introduced in:
afa837a361

$this->_nextValue = (int) $conn->query($sql)->fetchColumn();

Deprecated method query() calls ensureConnectedToPrimary() inside.
executeQuery() does not.

An exception occurred while executing 'SELECT NEXTVAL('...')':
SQLSTATE[25006]: Read only sql transaction: 7
Originally created by @lp-contentplus on GitHub (Oct 8, 2021). Issue introduced in: https://github.com/doctrine/orm/commit/afa837a3611490adbcf559fa9ea9db9dc04397a9 ``` $this->_nextValue = (int) $conn->query($sql)->fetchColumn(); ``` Deprecated method query() calls ensureConnectedToPrimary() inside. executeQuery() does not. ``` An exception occurred while executing 'SELECT NEXTVAL('...')': SQLSTATE[25006]: Read only sql transaction: 7 ```
admin added the Regression label 2026-01-22 15:40:08 +01:00
admin closed this issue 2026-01-22 15:40:08 +01:00
Author
Owner

@beberlei commented on GitHub (Oct 29, 2021):

Good catch. This should maybe use $conn->executeStatement($sql) instead?

@beberlei commented on GitHub (Oct 29, 2021): Good catch. This should maybe use `$conn->executeStatement($sql)` instead?
Author
Owner

@lp-contentplus commented on GitHub (Oct 29, 2021):

executeStatement also won't work (it returns the number of affected rows instead of the query result)
There is no direct replacement for query()

@lp-contentplus commented on GitHub (Oct 29, 2021): `executeStatement` also won't work (it returns the number of affected rows instead of the query result) There is no direct replacement for `query()`
Author
Owner

@anarxistkot commented on GitHub (Dec 3, 2021):

Are there any solution options?
We need doctrine/dbal version 3.2 :(

@anarxistkot commented on GitHub (Dec 3, 2021): Are there any solution options? We need doctrine/dbal version 3.2 :(
Author
Owner

@derrabus commented on GitHub (Dec 21, 2021):

Does 2.10.4 fix your issue?

@derrabus commented on GitHub (Dec 21, 2021): Does 2.10.4 fix your issue?
Author
Owner

@ottaviano commented on GitHub (Dec 22, 2021):

I just tested 2.10.4 and it works on my side, thanks

@ottaviano commented on GitHub (Dec 22, 2021): I just tested `2.10.4` and it works on my side, thanks
Author
Owner

@derrabus commented on GitHub (Dec 22, 2021):

All right, closing then. Thanks for verifying!

@derrabus commented on GitHub (Dec 22, 2021): All right, closing then. Thanks for verifying!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6857