Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1boVQ1-000555-Jc for pgsql-committers@arkaria.postgresql.org; Mon, 26 Sep 2016 12:54:01 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1boVQ1-00062p-6D for pgsql-committers@arkaria.postgresql.org; Mon, 26 Sep 2016 12:54:01 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1boVPz-0005x2-Ub for pgsql-committers@postgresql.org; Mon, 26 Sep 2016 12:54:00 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1boVPx-0008G1-7R for pgsql-committers@postgresql.org; Mon, 26 Sep 2016 12:53:58 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u8QCrp8Q027013; Mon, 26 Sep 2016 08:53:51 -0400 From: Tom Lane To: Michael Paquier cc: Peter Eisentraut , pgsql-committers@postgresql.org Subject: Re: pgsql: pg_ctl: Detect current standby state from pg_control In-reply-to: References: <18364.1474818887@sss.pgh.pa.us> Comments: In-reply-to Michael Paquier message dated "Mon, 26 Sep 2016 11:18:54 +0900" Date: Mon, 26 Sep 2016 08:53:51 -0400 Message-ID: <27012.1474894431@sss.pgh.pa.us> X-Pg-Spam-Score: -4.9 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-committers Precedence: bulk Sender: pgsql-committers-owner@postgresql.org Michael Paquier writes: > On Mon, Sep 26, 2016 at 12:54 AM, Tom Lane wrote: >> 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? Well, they certainly won't be using any untrustworthy reports if pg_controldata dumps core instead of printing the data, which is what will happen in HEAD. Although I don't understand your reference to needing a sleep. I think that it's 100% pointless for get_control_dbstate to be worried about transient CRC failures. If writes to pg_control aren't atomic then we have problems enormously larger than whether "pg_ctl promote" throws an error or not. > It seems to me that the correct fix here is that > pg_controldata.c should just exit like in the attached patch. No. Removing pg_controldata's designed-in ability to print information from corrupted pg_control files was not part of the advertised impact of this patch, and I will absolutely not hold still for it happening as an accidental consequence of ill-advised refactoring. It may well be that you need two different APIs for get_controlfile(), maybe with a flag, or two different wrappers around some common code. Or just go back to using #ifdef FRONTEND, and forget the silliness of expecting pg_ctl not to throw an error for bad pg_control content. BTW, now that get_controlfile has become a global symbol rather than something private to pg_controldata.c, I suggest that it needs a less generic name. "control file" could apply to a lot of things. Possibly "get_pg_control_contents" would be better. regards, tom lane -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers