Re: Libpq support to connect to standby server as priority

From: Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(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>
Subject: Re: Libpq support to connect to standby server as priority
Date: 2019-03-22 07:07:16
Message-ID: CAJrrPGd4YeA+N=xC+1XPVoGzMCATJZY4irVQEJ6i0aPqorUi7g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Mar 22, 2019 at 7:32 AM Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com>
wrote:

>
> On Fri, Mar 22, 2019 at 6:57 AM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>
>> On Thu, Mar 21, 2019 at 2:26 AM Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com>
>> wrote:
>> > Based on the above new options that can be added to
>> target_session_attrs,
>> >
>> > primary - it is just an alias to the read-write option.
>> > standby, prefer-standby - These options should check whether server is
>> running in recovery mode or not
>> > instead of checking whether server accepts read-only connections or not?
>>
>> I think it will be best to have one set of attributes that check
>> default_transaction_read_only and a differently-named set that check
>> pg_is_in_recovery(). For each, there should be one value that looks
>> for a 'true' return and one value that looks for a 'false' return and
>> perhaps values that accept either but prefer one or the other.
>>
>> IOW, there's no reason to make primary an alias for read-write. If
>> you want read-write, you can just say read-write. But we can make
>> 'primary' or 'master' look for a server that's not in recovery and
>> 'standby' look for one that is.
>>
>
> OK, I agree with opinion. I will produce a patch for those new options.
>

Here I attached WIP patch for the new options along with other older
patches.
The basic cases are working fine, doc and tests are missing.

Currently this patch doesn't implement the GUC_REPORT for recovery mode
yet. I am yet to optimize the complex if check.

Regards,
Haribabu Kommi
Fujitsu Australia

Attachment Content-Type Size
0001-Restructure-the-code-to-remove-duplicate-code.patch application/octet-stream 6.4 KB
0002-New-TargetSessionAttrsType-enum.patch application/octet-stream 3.0 KB
0005-New-read-only-target_session_attrs-type.patch application/octet-stream 7.3 KB
0003-Make-transaction_read_only-as-GUC_REPORT-varaible.patch application/octet-stream 9.6 KB
0004-New-prefer-read-target_session_attrs-type.patch application/octet-stream 14.1 KB
0006-Primary-prefer-standby-and-standby-options.patch application/octet-stream 12.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2019-03-22 07:39:30 Re: speeding up planning with partitions
Previous Message Masahiko Sawada 2019-03-22 06:45:37 Re: COPY FREEZE and setting PD_ALL_VISIBLE/visibility map bits