Skip to content

fix(openreader): Use READ COMMITTED to allow the usage of PostgreSQL replicas#449

Open
HRGCompany wants to merge 2 commits intosubsquid:masterfrom
HRGCompany:fix/openreader-read-committed-hot-standby
Open

fix(openreader): Use READ COMMITTED to allow the usage of PostgreSQL replicas#449
HRGCompany wants to merge 2 commits intosubsquid:masterfrom
HRGCompany:fix/openreader-read-committed-hot-standby

Conversation

@HRGCompany
Copy link

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 / processors pointing toward the primary server to avoid any overload.

…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.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 TRANSACTION isolation level from SERIALIZABLE to READ COMMITTED for 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>
@belopash
Copy link
Contributor

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?

program.description(`GraphQL server for squids`)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants