Skip to content

Use ReadOnly transaction when managing replication slots. #548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jmcclell
Copy link

@jmcclell jmcclell commented May 27, 2025

Postgres 16 introduced the ability to create logical replication slots directly on read only standby instances. Unfortunately, a read/write transaction cannot be started on a read only standby instance. This change introduces the ability to create a read only transaction and ensures that all operations involving logical replication slots use said transaction type.

This change is backwards compatible with older versions of Postgres and will work on both primary and standby instances.

This change does alter the error users receive on versions older than 16 when attempting to manage a logical replication slot on a read only standby instance. Today, all resources supported by this provider trigger the following error when attempting to create them on a read only standby:

Error: could not start transaction: pq: cannot set transaction read-write mode during recovery

After this change, this continues to be the case for all resources except replication slots, which will instead show the following error for Postgres versions < 16:

Error: pq: logical decoding cannot be used while in recovery

Postgres 16 introduced the ability to create logical replication slots
directly on read only standby instances. Unfortunately, a read/write
transaction cannot be started on a read only standby instance. This
change introduces the ability to create a read only transaction and
ensures that all operations involving replication slots use said
transaction type.

This change is backwards compatible with older versions of Postgres and
will work on both primary and standby instances.
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.

1 participant