Skip site navigation (1) Skip section navigation (2)

Re: Win32 Powerfail testing

From: "Magnus Hagander" <mha(at)sollentuna(dot)net>
To: "Dave Page" <dpage(at)vale-housing(dot)co(dot)uk>,"Kevin Brown" <kevin(at)sysexperts(dot)com>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Win32 Powerfail testing
Date: 2003-03-06 15:10:15
Message-ID: 81124B76C0CF364EBAC6CD213ABEDEF71D316A@ARGON.edu.sollentuna.se (view raw or flat)
Thread:
Lists: pgsql-hackers
> Agreed, but I still keep thinking that despite some peoples 
> claims that Windows ain't up to it, DB2, SQL and Exchange 
> Server as well a probably others that don't use raw 
> partitions have got over this problem, so therefore we should 
> be able to. Admittedly Microsoft have a bit of an advantage 
> over us, but there must be some accessible way of flushing 
> the buffers in a guaranteed way. I'll look into it some more 
> today if I can...

FWIW, I beleive all the mentioned products (Ok, at least SQL and
Exchange) use the CreateFile() API with the flag FILE_FLAG_NO_BUFFERING.
It has the following constraints, though, which they code around in the
app code I guess:

***
Instructs the system to open the file with no intermediate buffering or
caching. When combined with FILE_FLAG_OVERLAPPED, the flag gives maximum
asynchronous performance, because the I/O does not rely on the
synchronous operations of the memory manager. However, some I/O
operations will take longer, because data is not being held in the
cache. 
An application must meet certain requirements when working with files
opened with FILE_FLAG_NO_BUFFERING:


File access must begin at byte offsets within the file that are integer
multiples of the volume's sector size.

File access must be for numbers of bytes that are integer multiples of
the volume's sector size. For example, if the sector size is 512 bytes,
an application can request reads and writes of 512, 1024, or 2048 bytes,
but not of 335, 981, or 7171 bytes.

Buffer addresses for read and write operations should be sector aligned
(aligned on addresses in memory that are integer multiples of the
volume's sector size). Depending on the disk, this requirement may not
be enforced.

One way to align buffers on integer multiples of the volume sector size
is to use VirtualAlloc to allocate the buffers. It allocates memory that
is aligned on addresses that are integer multiples of the operating
system's memory page size. Because both memory page and volume sector
sizes are powers of 2, this memory is also aligned on addresses that are
integer multiples of a volume's sector size.

An application can determine a volume's sector size by calling the
GetDiskFreeSpace function.
***

There is also the flag FILE_FLAG_WRITE_THROUGH which says:
Instructs the system to write through any intermediate cache and go
directly to disk. The system can still cache write operations, but
cannot lazily flush them.



But that's the CreateFile() Win32 API. The question is how the fopen()
etc calls are mapped to Win32 calls, I'd guess.


//Magnus

pgsql-hackers by date

Next:From: Rod TaylorDate: 2003-03-06 15:10:50
Subject: Re: bug in contrib/adddepend
Previous:From: Bruce MomjianDate: 2003-03-06 14:58:20
Subject: Re: bug in contrib/adddepend

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group