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 1hnlK2-0002iW-5E for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Jul 2019 14:54:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hnlK1-0005Th-03 for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Jul 2019 14:54:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hnlK0-0005TY-O9 for pgsql-hackers@lists.postgresql.org; Wed, 17 Jul 2019 14:54:20 +0000 Received: from cyclops.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hnlJy-0002Ba-ON for pgsql-hackers@lists.postgresql.org; Wed, 17 Jul 2019 14:54:20 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 850F221C22C2; Wed, 17 Jul 2019 17:54:16 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from mail.postgrespro.ru (cyclops.l.postgrespro.ru [192.168.27.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 60D7721C22A6; Wed, 17 Jul 2019 17:54:16 +0300 (MSK) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 17 Jul 2019 21:54:16 +0700 From: r.zharkov@postgrespro.ru To: Tom Lane Cc: Badrul Chowdhury , pgsql-hackers@lists.postgresql.org Subject: Re: Intermittent pg_ctl failures on Windows In-Reply-To: <26631.1563371508@sss.pgh.pa.us> References: <16922.1520722108@sss.pgh.pa.us> <0057a0ce5a8893e4713a9a9d7e352162@postgrespro.ru> <26631.1563371508@sss.pgh.pa.us> Message-ID: <3b46fc8be044c79b5eff7d26c810d2fd@postgrespro.ru> X-Sender: r.zharkov@postgrespro.ru User-Agent: Roundcube Webmail/1.3.8 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-07-17 20:51, Tom Lane wrote: > 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. > You are right. I tested branch REL_11_STABLE and it is my mistake. >> 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. > The probability is very small. In one of our tests pg_ctl fails with that error sometime. In a test with multiple frequent restarts the probability is 5-6%. On other machines probability differs. To find out the real error code we used the Process Monitor utility. >> 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. > If we need parent cmd.exe only for log writing, can we start the postmaster without it? Is cmd.exe necessary? -- regards, Roman Zharkov