pgsql: Try again to work around Windows' ERROR_SHARING_VIOLATION in pg_ - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Try again to work around Windows' ERROR_SHARING_VIOLATION in pg_
Date
Msg-id E1j3Nan-0003AI-4d@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Try again to work around Windows' ERROR_SHARING_VIOLATION in pg_ctl.

Commit 0da33c762 introduced an unfortunate regression in pg_ctl on
Windows: if the log file specified with -l doesn't exist yet, and
pg_ctl is running with Administrator privileges, then the log file
might get created with permissions that prevent the postmaster from
writing on it.  (It seems that whether this happens depends on whether
the log file is inside the user's home directory or not, and perhaps
on other phase-of-the-moon conditions, which may explain why we failed
to notice it sooner.)

To fix, just don't create the log file if it doesn't exist yet.  The
case where we need to wait obviously only occurs with a pre-existing
log file.

In passing, switch from using fopen() to plain open(), saving a few
cycles.

Per bug #16259 from Jonathan Katz and Heath Lord.  Back-patch to v12,
as the faulty commit was.

Alexander Lakhin

Discussion: https://postgr.es/m/16259-c5ebed32a262a8b1@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e02ea141ee66e5b2372e1eb2d2000b7ed3a8e13a

Modified Files
--------------
src/bin/pg_ctl/pg_ctl.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pgsql: Logical Tape Set: lazily allocate read buffer.
Next
From: Fujii Masao
Date:
Subject: pgsql: Add description about LogicalRewriteTruncate wait event into doc