Re: Idea for fixing the Windows fsync problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Magnus Hagander" <magnus(at)hagander(dot)net>
Cc: tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Idea for fixing the Windows fsync problem
Date: 2007-01-17 15:35:29
Message-ID: 9972.1169048129@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Magnus Hagander" <magnus(at)hagander(dot)net> writes:
>> BTW: what happens on Windows if we're trying to do the equivalent
>> of "rm -rf database-dir" and someone is holding open one of the
>> files in the directory? Or has the directory itself open for readdir()?

> For the first definity and I think for the second, when doing it from the commandline, you get a 'cannot delete the directory because it is not empty'.
> I'm not sure if our implementation for dealing with open files also work with directories.

I just noticed this in dropdb():

/*
* On Windows, force a checkpoint so that the bgwriter doesn't hold any
* open files, which would cause rmdir() to fail.
*/
#ifdef WIN32
RequestCheckpoint(true, false);
#endif

This is done after flushing shared buffers (and, in a little bit, after
telling the bgwriter to forget pending fsyncs); so there'd be no reason
for the bgwriter to re-open any files in the victim database. And there
are other interlocks guaranteeing no active backends in the victim
database.

It's still not 100% bulletproof, because it's possible that some other
backend is holding an open file in the database as a consequence of
having had to dump some shared buffer for itself, but that should be
pretty darn rare if the bgwriter is getting its job done.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2007-01-17 15:48:37 Re: Temparary disable constraint
Previous Message Merlin Moncure 2007-01-17 15:31:25 Re: [PATCHES] pg_standby