fix(openreader): Use READ COMMITTED to allow the usage of PostgreSQL replicas#449
fix(openreader): Use READ COMMITTED to allow the usage of PostgreSQL replicas#449HRGCompany wants to merge 3 commits intosubsquid:masterfrom
Conversation
…replicas SERIALIZABLE isolation is incompatible with PostgreSQL replicas, causing "cannot use serializable mode on a hot standby" errors when OpenReader is pointed at a read-only replica. Since OpenReader only performs read queries, READ COMMITTED is sufficient and works correctly on both primary and replica servers. This allows distributing requests across replicas for read-only queries, while keeping indexers pointing toward the primary server to avoid any overload.
There was a problem hiding this comment.
Pull request overview
Updates OpenReader’s transaction isolation level to be compatible with PostgreSQL read-only replicas (hot standby), avoiding cannot use serializable mode on a hot standby errors while keeping queries read-only.
Changes:
- Change OpenReader’s
START TRANSACTIONisolation level fromSERIALIZABLEtoREAD COMMITTEDfor read-only transactions.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Hey, sorry for the long time reply. Could you please implement it as a configurable option, so It coiuld be passed to the server via command options? |
I’ve just pushed a new commit with the following changes. Would you mind reviewing it? Key Updates:
CockroachDB is updated from v21.2.9 → v23.2.2 (the old version was no longer available, which was blocking rush test). |
SERIALIZABLE isolation is incompatible with PostgreSQL replicas, causing "cannot use serializable mode on a hot standby" errors when OpenReader is pointed at a read-only replica.
Since OpenReader only performs read queries, READ COMMITTED is sufficient and works correctly on both primary and replica servers.
This PR adds support for configuring transaction isolation levels in the OpenReader and GraphQL Server packages, giving users more control over their query transactions.
This allows distributing requests across replicas for read-only queries, while keeping indexers / processors pointing toward the primary server to avoid any overload.
Default value is set to SERIALIZABLE to ensure backward compatibility and avoid breaking changes.