Re: Re: [COMMITTERS] pgsql: On Windows, when a file is deleted and another process still has

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Re: [COMMITTERS] pgsql: On Windows, when a file is deleted and another process still has
Date: 2009-09-11 14:51:36
Message-ID: 20412.1252680696@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> writes:
> Here's a patch implementing that, and changing pgrename() to check for
> ERROR_SHARING_VIOLATION and ERROR_LOCK_VIOLATION like pgwin32_open()
> does, instead of ERROR_ACCESS_DENIED.

This looks sane in a quick once-over, though I haven't tested it.
One tiny stylistic suggestion:

if (err != ERROR_SHARING_VIOLATION &&
err != ERROR_LOCK_VIOLATION)
#else
if (errno != EACCES)
#endif
return -1;
if (++loops > 300) /* time out after 30 sec */
return -1;

This is overly cute and will probably confuse both pgindent and ordinary
editors. It's worth one extra line to keep each part of the #if
syntactically independent, ie

if (err != ERROR_SHARING_VIOLATION &&
err != ERROR_LOCK_VIOLATION)
return -1;
#else
if (errno != EACCES)
return -1;
#endif
if (++loops > 300) /* time out after 30 sec */
return -1;

> I wonder if we should reduce the timeout in pgrename(). It's 30 s at the
> moment, but apparently it hasn't been working correctly, failing
> immediately instead if the file is locked.

I have a vague recollection that there was a specific reason for having
such a long timeout --- you might want to check the archives to see the
discussion before that code got committed. However, if nothing turns
up, I wouldn't object to reducing it to 5 or 10 sec.

regards, tom lane

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Magnus Hagander 2009-09-11 19:00:33 Re: Re: [COMMITTERS] pgsql: On Windows, when a file is deleted and another process still has
Previous Message User Mkz 2009-09-11 14:26:32 plproxy - plproxy: Fix argument value NULL check.

Browse pgsql-hackers by date

  From Date Subject
Next Message Emmanuel Cecchet 2009-09-11 14:53:33 Re: COPY enhancements
Previous Message Tom Lane 2009-09-11 14:40:30 Re: community decision-making & 8.5