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 1iekCJ-0004hV-S5 for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Dec 2019 18:25:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iekBJ-0007Iy-1e for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Dec 2019 18:24:21 +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 1iekBI-0007Ir-MR for pgsql-bugs@lists.postgresql.org; Tue, 10 Dec 2019 18:24:20 +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 1iekBC-000306-1M for pgsql-bugs@lists.postgresql.org; Tue, 10 Dec 2019 18:24:19 +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 xBAIOAnM023007; Tue, 10 Dec 2019 13:24:11 -0500 From: Tom Lane To: Alexander Law cc: Amit Kapila , PostgreSQL mailing lists Subject: Re: BUG #16154: pg_ctl restart with a logfile fails sometimes (on Windows) In-reply-to: References: <16154-1ccf0b537b24d5e0@postgresql.org> <29331.1575737694@sss.pgh.pa.us> <3039.1575746766@sss.pgh.pa.us> Comments: In-reply-to Alexander Law message dated "Sun, 08 Dec 2019 00:00:00 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <23005.1576002250.1@sss.pgh.pa.us> Date: Tue, 10 Dec 2019 13:24:10 -0500 Message-ID: <23006.1576002250@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alexander Law writes: > 07.12.2019 22:26 Tom Lane : >> It seems like it'd be cleaner to fix both of these things at once >> by opening the logfile ourselves (rather than letting CMD.EXE do it) >> and using sharing-friendly parameters at that point. But maybe it's >> just not worth the trouble compared to the individual hacks. > If we couldn't find more advantages of rewriting create process (with > logfile), I would restrict changes to one hack (or two, if really needed). Yeah, I agree that it doesn't yet seem worthwhile to do that sort of rewrite. Also, I realized that blaming CMD.EXE for holding the logfile open is wrong: it's actually the postmaster itself that still has the file open after it's removed postmaster.pid. (Well, maybe CMD.EXE still has a handle too, but that would be weird; and it's not necessary to explain the problem.) Short of doing our own redirection, the only way to fix that would be for the postmaster to close its own stdout and stderr before removing the pidfile, which is obviously a bad idea. Hence, I pushed this patch, with a revised comment. We'll see how it affects the buildfarm. regards, tom lane