RE: Libpq support to connect to standby server as priority

From: "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>
To: 'Haribabu Kommi' <kommi(dot)haribabu(at)gmail(dot)com>
Cc: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Dave Cramer <pg(at)fastcrypt(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, "Jing Wang" <jingwangian(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: Libpq support to connect to standby server as priority
Date: 2019-01-18 06:20:56
Message-ID: 0A3221C70F24FB45833433255569204D1FB6990A@G01JPEXMBYT05
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

From: Haribabu Kommi [mailto:kommi(dot)haribabu(at)gmail(dot)com]
> IMO, if we try to use only pg_is_in_recovery() only to decide to connect,
> we may not
> support all the target_session_attrs that are possible. how about using
> both to decide?

I favor adding a new parameter like target_server_type whose purpose is to select the server role. That aligns better with the PgJDBC's naming, which conveys consistency to PostgreSQL users. Again, the original desire should have been to connect to a standby to eliminate the burdon on the primary, where the primary may be read-only by default and only a limited group of users are allowed to write to the database.

I don't know what kind of realistic use cases there are that request read-only session in the logical replication configuration. I think we can just leave target_session_attrs as what it is now in PostgreSQL 11, for compatibility and possibly future new use cases.

> Master/read-write -- recovery = false and default_transaction_read_only
> = false
> Standby/read-only -- recovery = true
> prefer-standby/prefer-read -- recovery = true or
> default_transaction_read_only = true
> any -- Nothing to be verified
>
>
> I feel above verifications can cover for both physical and logical
> replication.

As for prefer-standby/prefer-read, if host parameter specifies host1,host2 in this order, and host1 is the primary with default_transaction_read_only=true, does the app get a connection to host1? I want to connect to host2 (standby) only if host1 is down.

Regards
Takayuki Tsunakawa

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2019-01-18 06:28:13 Re: Libpq support to connect to standby server as priority
Previous Message Tom Lane 2019-01-18 06:18:44 Re: PSA: we lack TAP test coverage on NetBSD and OpenBSD