Re: pgsql: pg_ctl: Detect current standby state from pg_control

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: pg_ctl: Detect current standby state from pg_control
Date: 2016-09-26 02:18:54
Message-ID: CAB7nPqQfktJ5rd1g+hXhKaSaUQk3y=4eydNLG2sOw8chAvY2cw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Mon, Sep 26, 2016 at 12:54 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
>> pg_ctl: Detect current standby state from pg_control
>
> Coverity thinks that this patch introduced a bunch of
> null-pointer-dereference hazards, and AFAICS it is right.
> The change in get_controlfile()'s API is completely broken
> and needs to be undone.

So you'd rather have a sleep(1) and complicate this code to replace it
with a WaitLatch() when the code is used by the backend? I don't agree
with that as the new API is cleaner as presented, though I agree that
it is a change that caller does not get any result in case of a CRC
mismatch, but who's going to use results that cannot be trusted
anyway? It seems to me that the correct fix here is that
pg_controldata.c should just exit like in the attached patch. Somewhat
I missed that during my lookup of c1dc51d4.

If we would still want callers of get_controlfile() to be allowed to
read untrustworthy results, we could just add a boolean status flag..
--
Michael

Attachment Content-Type Size
controldata-untrust.patch application/x-download 742 bytes

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2016-09-26 07:56:48 pgsql: Refactor script execution state machine in pgbench.
Previous Message Tom Lane 2016-09-25 19:41:20 pgsql: Refer to OS X as "macOS", except for the port name which is stil

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2016-09-26 02:32:18 Re: Stopping logical replication protocol
Previous Message Robert Haas 2016-09-26 01:51:51 Re: store narrow values in hash indexes?