RE: Libpq support to connect to standby server as priority

From: "tsunakawa(dot)takay(at)fujitsu(dot)com" <tsunakawa(dot)takay(at)fujitsu(dot)com>
To: 'Alvaro Herrera' <alvherre(at)2ndquadrant(dot)com>
Cc: Greg Nancarrow <gregn4422(at)gmail(dot)com>, Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, 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>, Jing Wang <jingwangian(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Elvis Pranskevichus <elprans(at)gmail(dot)com>
Subject: RE: Libpq support to connect to standby server as priority
Date: 2019-12-27 01:26:03
Message-ID: OSAPR01MB5073A42A6540FB1861CFB35EFE2A0@OSAPR01MB5073.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
> I'm not sure I understand why we end up with "prefer-read" in addition
> to "prefer-standby" (and similar seeming redundancy between "primary"
> and "read-write"). Do we really need more than one way to identify
> hosts' roles? It seems 0001 adds the "prefer-read" modes by checking
> transaction_read_only, and later 0002 adds the "prefer-standby" modes by
> checking in_recovery. I'm not sure that we're serving our users very
> well by giving them choice that ends up being confusing. In other words
> I think we should do only one of these things, not both. Maybe merge
> 0001 and 0002 in a single patch, and get rid of redundant modes.

That's because the distinction read/write is different from primary/standby. If default_transaction_read_only is on, even the primary is read-only. That's why the syntax target_session_attrs = {read-write | read-only} was introduced instead of target_server_type = {primary | standby}. Personally, I only want target_server_type = {primary | standby | prefer-standby}, and discard target_session_attrs for simplicity of the functional specification and the code.

> Also, Ishii-san said:
> https://postgr.es/m/20190116.150236.2304777214520289427.t-ishii@sraoss.c
> o.jp
> - When looking for a primary, find a node where pg_is_in_recovery is
> false; if none, libpq should retry until a timeout expires. Did we
> reject this idea altogether, or is it just unimplemented?

I don't remember well, but I guess this is for eliminating the need for applications to retry connection attempts during the database server failover. I think that will be convenient, but not mandatory for this patch. PgJDBC doesn't provide it, either.

Regards
Takayuki Tsunakawa

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nikita Glukhov 2019-12-27 01:36:14 Re: Avoid full GIN index scan when possible
Previous Message Tom Lane 2019-12-27 00:07:17 Re: pgsql: Superuser can permit passwordless connections on postgres_fdw