Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hnkLZ-0008WS-IR for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Jul 2019 13:51:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hnkLY-0007ml-Bw for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Jul 2019 13:51:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hnkLY-0007me-0T for pgsql-hackers@lists.postgresql.org; Wed, 17 Jul 2019 13:51:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1hnkLV-00054T-Pi for pgsql-hackers@lists.postgresql.org; Wed, 17 Jul 2019 13:51:50 +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 x6HDpmne026632; Wed, 17 Jul 2019 09:51:48 -0400 From: Tom Lane To: r.zharkov@postgrespro.ru cc: Badrul Chowdhury , pgsql-hackers@lists.postgresql.org Subject: Re: Intermittent pg_ctl failures on Windows In-reply-to: <0057a0ce5a8893e4713a9a9d7e352162@postgrespro.ru> References: <16922.1520722108@sss.pgh.pa.us> <0057a0ce5a8893e4713a9a9d7e352162@postgrespro.ru> Comments: In-reply-to r.zharkov@postgrespro.ru message dated "Wed, 17 Jul 2019 17:40:36 +0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <26630.1563371508.1@sss.pgh.pa.us> Date: Wed, 17 Jul 2019 09:51:48 -0400 Message-ID: <26631.1563371508@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk r.zharkov@postgrespro.ru writes: > pg_ctl now opens the postmaster.pid file using pgwin32_open() function > to correctly handle share locks. HEAD already does that, no? See f02259fe9. > On Windows systems we cannot handle ERROR_DELETE_PENDING because > GetLastError() returns ERROR_ACCESS_DENIED instead. > So we rename the lock files before delete them. This seems improbably broken/stupid. Also, I've not seen any buildfarm failures that would match this; it's always pg_ctl complaining not the postmaster. > To avoid the second error we added the wait for cmd.exe finish in the > do_stop() and do_restart() functions. Hmmm ... there seems the germ of a good idea here, but can't we do it with less (and less ugly) code? Alternatively, perhaps we could fix things so that the parent cmd.exe shell isn't involved in logfile access? That'd require teaching the postmaster to open/redirect its stdout/stderr, which is kind of annoying, but it might beat hacking things as you have done here. regards, tom lane