*** pgsql/src/backend/access/transam/xlog.c 2009/09/10 09:42:10 1.352 --- pgsql/src/backend/access/transam/xlog.c 2009/09/13 18:32:07 1.353 *************** *** 7,13 **** * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * ! * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.351 2009/09/01 02:54:51 alvherre Exp $ * *------------------------------------------------------------------------- */ --- 7,13 ---- * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * ! * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.352 2009/09/10 09:42:10 heikki Exp $ * *------------------------------------------------------------------------- */ *************** XLogFileInit(uint32 log, uint32 seg, *** 2262,2273 **** *use_existent, &max_advance, use_lock)) { ! /* No need for any more future segments... */ unlink(tmppath); } - elog(DEBUG2, "done creating and filling new WAL file"); - /* Set flag to tell caller there was no existent file */ *use_existent = false; --- 2262,2275 ---- *use_existent, &max_advance, use_lock)) { ! /* ! * No need for any more future segments, or InstallXLogFileSegment() ! * failed to rename the file into place. If the rename failed, opening ! * the file below will fail. ! */ unlink(tmppath); } /* Set flag to tell caller there was no existent file */ *use_existent = false; *************** XLogFileInit(uint32 log, uint32 seg, *** 2280,2285 **** --- 2282,2289 ---- errmsg("could not open file \"%s\" (log file %u, segment %u): %m", path, log, seg))); + elog(DEBUG2, "done creating and filling new WAL file"); + return fd; } *************** XLogFileCopy(uint32 log, uint32 seg, *** 2409,2418 **** * place. This should be TRUE except during bootstrap log creation. The * caller must *not* hold the lock at call. * ! * Returns TRUE if file installed, FALSE if not installed because of ! * 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, --- 2413,2421 ---- * place. This should be TRUE except during bootstrap log creation. The * caller must *not* hold the lock at call. * ! * Returns TRUE if the file was installed successfully. FALSE indicates that ! * max_advance limit was exceeded, or an error occurred while renaming the ! * file into place. */ static bool InstallXLogFileSegment(uint32 *log, uint32 *seg, char *tmppath, *************** InstallXLogFileSegment(uint32 *log, uint *** 2460,2490 **** */ #if HAVE_WORKING_LINK if (link(tmppath, path) < 0) ! ereport(ERROR, (errcode_for_file_access(), errmsg("could not link file \"%s\" to \"%s\" (initialization of log file %u, segment %u): %m", tmppath, path, *log, *seg))); 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 --- 2463,2488 ---- */ #if HAVE_WORKING_LINK if (link(tmppath, path) < 0) ! { ! if (use_lock) ! LWLockRelease(ControlFileLock); ! ereport(LOG, (errcode_for_file_access(), errmsg("could not link file \"%s\" to \"%s\" (initialization of log file %u, segment %u): %m", tmppath, path, *log, *seg))); + return false; + } unlink(tmppath); #else if (rename(tmppath, path) < 0) { ! if (use_lock) ! LWLockRelease(ControlFileLock); ! ereport(LOG, (errcode_for_file_access(), errmsg("could not rename file \"%s\" to \"%s\" (initialization of log file %u, segment %u): %m", tmppath, path, *log, *seg))); + return false; } #endif *************** RemoveOldXlogFiles(uint32 log, uint32 se *** 3128,3146 **** */ snprintf(newpath, MAXPGPATH, "%s.deleted", path); if (rename(path, newpath) != 0) ! ereport(ERROR, (errcode_for_file_access(), ! errmsg("could not rename old transaction log file \"%s\"", path))); rc = unlink(newpath); #else rc = unlink(path); #endif if (rc != 0) ! ereport(ERROR, (errcode_for_file_access(), errmsg("could not remove old transaction log file \"%s\": %m", path))); CheckpointStats.ckpt_segs_removed++; } --- 3126,3150 ---- */ snprintf(newpath, MAXPGPATH, "%s.deleted", path); if (rename(path, newpath) != 0) ! { ! ereport(LOG, (errcode_for_file_access(), ! errmsg("could not rename old transaction log file \"%s\": %m", path))); + continue; + } rc = unlink(newpath); #else rc = unlink(path); #endif if (rc != 0) ! { ! ereport(LOG, (errcode_for_file_access(), errmsg("could not remove old transaction log file \"%s\": %m", path))); + continue; + } CheckpointStats.ckpt_segs_removed++; }