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 1igbQe-0007Pt-Gr for pgsql-bugs@arkaria.postgresql.org; Sun, 15 Dec 2019 21:27:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1igbPe-0008O2-Ah for pgsql-bugs@arkaria.postgresql.org; Sun, 15 Dec 2019 21:26:50 +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 1igbPd-0008Nt-Vg for pgsql-bugs@lists.postgresql.org; Sun, 15 Dec 2019 21:26:50 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1igbPX-0002P5-KS for pgsql-bugs@lists.postgresql.org; Sun, 15 Dec 2019 21:26:48 +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 xBFLQehE031099; Sun, 15 Dec 2019 16:26:40 -0500 From: Tom Lane To: Alexander Lakhin cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16161: pg_ctl stop fails sometimes (on Windows) In-reply-to: <4d28c7e1-fe91-b9fd-3227-478e549b05d5@gmail.com> References: <16161-7a985d2f1bbe8f71@postgresql.org> <4d28c7e1-fe91-b9fd-3227-478e549b05d5@gmail.com> Comments: In-reply-to Alexander Lakhin message dated "Wed, 11 Dec 2019 23:30:01 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <31097.1576445200.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 15 Dec 2019 16:26:40 -0500 Message-ID: <31098.1576445200@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alexander Lakhin writes: >> The regression tests on Windows sometimes fail with 'Permission denied' >> errors. For example: >> https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=3Ddory&dt=3D201= 9-12-11%2007%3A45%3A33 > I see two ways to fix the issue: > 1) Unlink postmaster.pid using rename operation (adopt the solution from > https://stackoverflow.com/questions/3764072/). > 2) Ignore such 'Permission denied' error and just try to open the file > once again (attached fix_open_for_unlink.patch implements this). > I'm inclined to the second approach as pgwin32_open() already handles > two transient states (Windows-only), and it could be useful not only for > postmaster.pid, but for some other files. Agreed that (2) seems like the way to go. However, I'm not too pleased with the patch as given, because it is gratuitously different in almost every possible way from the adjacent code that's doing just about the same thing for those other transient failures. Why is the timeout duration different? Why is the looping logic not identical? Why did you make a different decision about whether logging might be a good idea? Actually, why didn't you just extend the existing if-block to also cover this case? Maybe there's good reasons to be different, but you didn't explain them. I'm also not that excited about memorializing a stackoverflow discussion as the reason to do something. Can we point to something in Microsoft's official docs? regards, tom lane