Re: BUG #16154: pg_ctl restart with a logfile fails sometimes (on Windows)
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alexander Law <exclusion@gmail.com>
Cc: Amit Kapila <amit.kapila16@gmail.com>,
PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Date: 2019-12-10T18:24:10Z
Lists: pgsql-bugs
Alexander Law <exclusion@gmail.com> writes: > 07.12.2019 22:26 Tom Lane <tgl@sss.pgh.pa.us>: >> 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
Commits
-
In pg_ctl, work around ERROR_SHARING_VIOLATION on the postmaster log file.
- be9d4b928060 12.2 landed
- 0da33c762b85 13.0 landed