MagicStack / asyncpg

A fast PostgreSQL Database Client Library for Python/asyncio.
Apache License 2.0
6.99k stars 404 forks source link

Add target session attribute connection param #953

Closed ronyb29 closed 1 year ago

JesseDeLoore commented 2 years ago

@elprans Is there anything I can do to help move this PR along ?

elprans commented 2 years ago

Please rebase. This seems to be on top of an ancient revision.

ronyb29 commented 2 years ago

hey guys, Apart from the ones in this PR libpq also has read-write and read-only, but I didn't see much use for them, I got the impression they were the "old" version of the attributes.

Is there a scenario where those are still valuable? or are primary and standby and prefer_standby enough for practical use cases?

JesseDeLoore commented 2 years ago

from This blogpost on https://www.cybertec-postgresql.com

PostgreSQL v14 introduces these new options:

read-only: only connect to a server that does not allow data modifications. This is the converse of read-write.
primary: only connect to a database that is not a streaming replication standby.
standby: only connect to a streaming replication standby.
prefer-standby: connect to a standby server if there is one. Only if there is no standby server on the list, accept a connection to a server that is not in recovery mode.
You are probably confused by the distinction between “read-only” and “standby” or between “read-write” and “primary”.
The difference is subtle: if the parameter “default_transaction_read_only” is set to “on”, a server can be read-only even if it is not a streaming replication standby server.

So it looks like there is a subtle difference and a use case for read-write and read-only

JesseDeLoore commented 1 year ago

@ronyb29 is there anything I can do to help ?

JesseDeLoore commented 1 year ago

@ronyb29 do you intend to finish this PR? If not (or unresponsive) I'll fork your fork as it is a good start and make my own PR.

elprans commented 1 year ago

Superseded by #987