aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlog.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-11-08 20:12:05 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-11-08 20:12:05 +0000
commitdcbdf9b1d46dc9f95c55f78da4754ded4f0cd17d (patch)
tree1491476e2bd79f27b13abb429512793cabb526b4 /src/backend/access/transam/xlog.c
parent808b3190d143f3df7217f94aff9e97fdf19c790a (diff)
downloadpostgresql-dcbdf9b1d46dc9f95c55f78da4754ded4f0cd17d.tar.gz
postgresql-dcbdf9b1d46dc9f95c55f78da4754ded4f0cd17d.zip
Change Windows rename and unlink substitutes so that they time out after
30 seconds instead of retrying forever. Also modify xlog.c so that if it fails to rename an old xlog segment up to a future slot, it will unlink the segment instead. Per discussion of bug #2712, in which it became apparent that Windows can handle unlinking a file that's being held open, but not renaming it.
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r--src/backend/access/transam/xlog.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 03440cbf48b..9b590061731 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.253 2006/11/05 22:42:08 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.254 2006/11/08 20:12:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2140,7 +2140,9 @@ XLogFileCopy(uint32 log, uint32 seg,
* caller must *not* hold the lock at call.
*
* Returns TRUE if file installed, FALSE if not installed because of
- * exceeding max_advance limit. (Any other kind of failure causes ereport().)
+ * exceeding max_advance limit. On Windows, we also return FALSE if we
+ * can't rename the file into place because someone's got it open.
+ * (Any other kind of failure causes ereport().)
*/
static bool
InstallXLogFileSegment(uint32 *log, uint32 *seg, char *tmppath,
@@ -2195,10 +2197,25 @@ InstallXLogFileSegment(uint32 *log, uint32 *seg, char *tmppath,
unlink(tmppath);
#else
if (rename(tmppath, path) < 0)
+ {
+#ifdef WIN32
+#if !defined(__CYGWIN__)
+ if (GetLastError() == ERROR_ACCESS_DENIED)
+#else
+ if (errno == EACCES)
+#endif
+ {
+ if (use_lock)
+ LWLockRelease(ControlFileLock);
+ return false;
+ }
+#endif /* WIN32 */
+
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not rename file \"%s\" to \"%s\" (initialization of log file %u, segment %u): %m",
tmppath, path, *log, *seg)));
+ }
#endif
if (use_lock)