of checkpoint. Although the checkpoint has been written to WAL at that point already, so that all data is safe, and we'll retry removing the WAL segment at the next checkpoint, if such a failure persists we won't be able to remove any other old WAL segments either and will eventually run out of disk space. It's better to treat the failure as non-fatal, and move on to clean any other WAL segment and continue with any other end-of-checkpoint cleanup. We don't normally expect any such failures, but on Windows it can happen with some anti-virus or backup software that lock files without FILE_SHARE_DELETE flag. Also, the loop in pgrename() to retry when the file is locked was broken. If a file is locked on Windows, you get ERROR_SHARE_VIOLATION, not ERROR_ACCESS_DENIED, at least on modern versions. Fix that, although I left the check for ERROR_ACCESS_DENIED in there as well (presumably it was correct in some environment), and added ERROR_LOCK_VIOLATION to be consistent with similar checks in pgwin32_open(). Reduce the timeout on the loop from 30s to 10s, on the grounds that since it's been broken, we've effectively had a timeout of 0s and no-one has complained, so a smaller timeout is actually closer to the old behavior. A longer timeout would mean that if recycling a WAL file fails because it's locked for some reason, InstallXLogFileSegment() will hold ControlFileLock for longer, potentially blocking other backends, so a long timeout isn't totally harmless. While we're at it, set errno correctly in pgrename(). Backpatch to 8.2, which is the oldest version supported on Windows. The xlog.c changes would make sense on other platforms and thus on older versions as well, but since there's no such locking issues on other platforms, it's not worth it. |
||
---|---|---|
.. | ||
Makefile | ||
README | ||
chklocale.c | ||
copydir.c | ||
crypt.c | ||
dirent.c | ||
dirmod.c | ||
erand48.c | ||
exec.c | ||
fseeko.c | ||
getaddrinfo.c | ||
gethostname.c | ||
getopt.c | ||
getopt_long.c | ||
getrusage.c | ||
gettimeofday.c | ||
inet_aton.c | ||
isinf.c | ||
kill.c | ||
memcmp.c | ||
noblock.c | ||
open.c | ||
path.c | ||
pgsleep.c | ||
pgstrcasecmp.c | ||
pipe.c | ||
pthread-win32.h | ||
qsort.c | ||
qsort_arg.c | ||
random.c | ||
rint.c | ||
snprintf.c | ||
sprompt.c | ||
srandom.c | ||
strdup.c | ||
strerror.c | ||
strlcat.c | ||
strlcpy.c | ||
strtol.c | ||
strtoul.c | ||
thread.c | ||
unsetenv.c | ||
win32.ico | ||
win32env.c | ||
win32error.c | ||
win32ver.rc |
README
$PostgreSQL: pgsql/src/port/README,v 1.4 2008/03/21 13:23:29 momjian Exp $ libpgport ========= libpgport must have special behavior. It supplies functions to both libraries and applications. However, there are two complexities: 1) Libraries need to use object files that are compiled with exactly the same flags as the library. libpgport might not use the same flags, so it is necessary to recompile the object files for individual libraries. This is done by removing -lpgport from the link line: # Need to recompile any libpgport object files LIBS := $(filter-out -lpgport, $(LIBS)) and adding infrastructure to recompile the object files: OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \ connect.o misc.o path.o exec.o \ $(filter snprintf.o, $(LIBOBJS)) The problem is that there is no testing of which object files need to be added, but missing functions usually show up when linking user applications. 2) For applications, we use -lpgport before -lpq, so the static files from libpgport are linked first. This avoids having applications dependent on symbols that are _used_ by libpq, but not intended to be exported by libpq. libpq's libpgport usage changes over time, so such a dependency is a problem. Win32, Linux, and Darwin use an export list to control the symbols exported by libpq.