diff options
author | Robert Haas <rhaas@postgresql.org> | 2016-10-20 11:24:37 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2016-10-20 11:32:18 -0400 |
commit | f82ec32ac30ae7e3ec7c84067192535b2ff8ec0e (patch) | |
tree | 929d4709a42149a4bbde12edad16183a96bcef6a /src | |
parent | ec7db2b483e0ff247ed41612cdb5716022401fe6 (diff) | |
download | postgresql-f82ec32ac30ae7e3ec7c84067192535b2ff8ec0e.tar.gz postgresql-f82ec32ac30ae7e3ec7c84067192535b2ff8ec0e.zip |
Rename "pg_xlog" directory to "pg_wal".
"xlog" is not a particularly clear abbreviation for "write-ahead log",
and it sometimes confuses users into believe that the contents of the
"pg_xlog" directory are not critical data, leading to unpleasant
consequences. So, rename the directory to "pg_wal".
This patch modifies pg_upgrade and pg_basebackup to understand both
the old and new directory layouts; the former is necessary given the
purpose of the tool, while the latter merely avoids an unnecessary
backward-compatibility break.
We may wish to consider renaming other programs, switches, and
functions which still use the old "xlog" naming to also refer to
"wal". However, that's still under discussion, so let's do just this
much for now.
Discussion: CAB7nPqTeC-8+zux8_-4ZD46V7YPwooeFxgndfsq5Rg8ibLVm1A@mail.gmail.com
Michael Paquier
Diffstat (limited to 'src')
24 files changed, 232 insertions, 179 deletions
diff --git a/src/backend/access/transam/timeline.c b/src/backend/access/transam/timeline.c index bd91573708b..43436a97a91 100644 --- a/src/backend/access/transam/timeline.c +++ b/src/backend/access/transam/timeline.c @@ -43,7 +43,7 @@ /* * Copies all timeline history files with id's between 'begin' and 'end' - * from archive to pg_xlog. + * from archive to pg_wal. */ void restoreTimeLineHistoryFiles(TimeLineID begin, TimeLineID end) @@ -191,7 +191,7 @@ readTimeLineHistory(TimeLineID targetTLI) result = lcons(entry, result); /* - * If the history file was fetched from archive, save it in pg_xlog for + * If the history file was fetched from archive, save it in pg_wal for * future reference. */ if (fromArchive) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 08c87f91be6..4fda1798ccd 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -235,9 +235,9 @@ static int LocalXLogInsertAllowed = -1; * valid in the startup process. * * When ArchiveRecoveryRequested is true, but InArchiveRecovery is false, we're - * currently performing crash recovery using only XLOG files in pg_xlog, but + * currently performing crash recovery using only XLOG files in pg_wal, but * will switch to using offline XLOG archives as soon as we reach the end of - * WAL in pg_xlog. + * WAL in pg_wal. */ bool ArchiveRecoveryRequested = false; bool InArchiveRecovery = false; @@ -700,12 +700,12 @@ typedef enum { XLOG_FROM_ANY = 0, /* request to read WAL from any source */ XLOG_FROM_ARCHIVE, /* restored using restore_command */ - XLOG_FROM_PG_XLOG, /* existing file in pg_xlog */ + XLOG_FROM_PG_WAL, /* existing file in pg_wal */ XLOG_FROM_STREAM /* streamed from master */ } XLogSource; /* human-readable names for XLogSources, for debugging output */ -static const char *xlogSourceNames[] = {"any", "archive", "pg_xlog", "stream"}; +static const char *xlogSourceNames[] = {"any", "archive", "pg_wal", "stream"}; /* * openLogFile is -1 or a kernel FD for an open log file segment. @@ -3345,7 +3345,7 @@ XLogFileOpen(XLogSegNo segno) * Open a logfile segment for reading (during recovery). * * If source == XLOG_FROM_ARCHIVE, the segment is retrieved from archive. - * Otherwise, it's assumed to be already available in pg_xlog. + * Otherwise, it's assumed to be already available in pg_wal. */ static int XLogFileRead(XLogSegNo segno, int emode, TimeLineID tli, @@ -3374,7 +3374,7 @@ XLogFileRead(XLogSegNo segno, int emode, TimeLineID tli, return -1; break; - case XLOG_FROM_PG_XLOG: + case XLOG_FROM_PG_WAL: case XLOG_FROM_STREAM: XLogFilePath(path, tli, segno); restoredFromArchive = false; @@ -3393,7 +3393,7 @@ XLogFileRead(XLogSegNo segno, int emode, TimeLineID tli, KeepFileRestoredFromArchive(path, xlogfname); /* - * Set path to point at the new file in pg_xlog. + * Set path to point at the new file in pg_wal. */ snprintf(path, MAXPGPATH, XLOGDIR "/%s", xlogfname); } @@ -3481,10 +3481,10 @@ XLogFileReadAnyTLI(XLogSegNo segno, int emode, int source) } } - if (source == XLOG_FROM_ANY || source == XLOG_FROM_PG_XLOG) + if (source == XLOG_FROM_ANY || source == XLOG_FROM_PG_WAL) { fd = XLogFileRead(segno, emode, tli, - XLOG_FROM_PG_XLOG, true); + XLOG_FROM_PG_WAL, true); if (fd != -1) { if (!expectedTLEs) @@ -3693,10 +3693,10 @@ RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr PriorRedoPtr, XLogRecPtr endptr) * * This is called during recovery, whenever we switch to follow a new * timeline, and at the end of recovery when we create a new timeline. We - * wouldn't otherwise care about extra WAL files lying in pg_xlog, but they + * wouldn't otherwise care about extra WAL files lying in pg_wal, but they * might be leftover pre-allocated or recycled WAL segments on the old timeline * that we haven't used yet, and contain garbage. If we just leave them in - * pg_xlog, they will eventually be archived, and we can't let that happen. + * pg_wal, they will eventually be archived, and we can't let that happen. * Files that belong to our timeline history are valid, because we have * successfully replayed them, but from others we can't be sure. * @@ -3853,15 +3853,15 @@ RemoveXlogFile(const char *segname, XLogRecPtr PriorRedoPtr, XLogRecPtr endptr) } /* - * Verify whether pg_xlog and pg_xlog/archive_status exist. + * Verify whether pg_wal and pg_wal/archive_status exist. * If the latter does not exist, recreate it. * * It is not the goal of this function to verify the contents of these * directories, but to help in cases where someone has performed a cluster - * copy for PITR purposes but omitted pg_xlog from the copy. + * copy for PITR purposes but omitted pg_wal from the copy. * - * We could also recreate pg_xlog if it doesn't exist, but a deliberate - * policy decision was made not to. It is fairly common for pg_xlog to be + * We could also recreate pg_wal if it doesn't exist, but a deliberate + * policy decision was made not to. It is fairly common for pg_wal to be * a symlink, and if that was the DBA's intent then automatically making a * plain directory would result in degraded performance with no notice. */ @@ -3871,7 +3871,7 @@ ValidateXLOGDirectoryStructure(void) char path[MAXPGPATH]; struct stat stat_buf; - /* Check for pg_xlog; if it doesn't exist, error out */ + /* Check for pg_wal; if it doesn't exist, error out */ if (stat(XLOGDIR, &stat_buf) != 0 || !S_ISDIR(stat_buf.st_mode)) ereport(FATAL, @@ -4027,11 +4027,11 @@ ReadRecord(XLogReaderState *xlogreader, XLogRecPtr RecPtr, int emode, * If archive recovery was requested, but we were still doing * crash recovery, switch to archive recovery and retry using the * offline archive. We have now replayed all the valid WAL in - * pg_xlog, so we are presumably now consistent. + * pg_wal, so we are presumably now consistent. * * We require that there's at least some valid WAL present in - * pg_xlog, however (!fetch_ckpt). We could recover using the WAL - * from the archive, even if pg_xlog is completely empty, but we'd + * pg_wal, however (!fetch_ckpt). We could recover using the WAL + * from the archive, even if pg_wal is completely empty, but we'd * have no idea how far we'd have to replay to reach consistency. * So err on the safe side and give up. */ @@ -4039,7 +4039,7 @@ ReadRecord(XLogReaderState *xlogreader, XLogRecPtr RecPtr, int emode, !fetching_ckpt) { ereport(DEBUG1, - (errmsg_internal("reached end of WAL in pg_xlog, entering archive recovery"))); + (errmsg_internal("reached end of WAL in pg_wal, entering archive recovery"))); InArchiveRecovery = true; if (StandbyModeRequested) StandbyMode = true; @@ -4156,7 +4156,7 @@ rescanLatestTimeLine(void) /* * As in StartupXLOG(), try to ensure we have all the history files - * between the old target and new target in pg_xlog. + * between the old target and new target in pg_wal. */ restoreTimeLineHistoryFiles(oldtarget + 1, newtarget); @@ -5189,7 +5189,7 @@ readRecoveryCommandFile(void) ereport(WARNING, (errmsg("recovery command file \"%s\" specified neither primary_conninfo nor restore_command", RECOVERY_COMMAND_FILE), - errhint("The database server will regularly poll the pg_xlog subdirectory to check for files placed there."))); + errhint("The database server will regularly poll the pg_wal subdirectory to check for files placed there."))); } else { @@ -6056,7 +6056,7 @@ StartupXLOG(void) #endif /* - * Verify that pg_xlog and pg_xlog/archive_status exist. In cases where + * Verify that pg_wal and pg_wal/archive_status exist. In cases where * someone has performed a copy for PITR, these directories may have been * excluded and need to be re-created. */ @@ -6269,7 +6269,7 @@ StartupXLOG(void) * and put it into archive recovery by creating a recovery.conf file. * * Our strategy in that case is to perform crash recovery first, - * replaying all the WAL present in pg_xlog, and only enter archive + * replaying all the WAL present in pg_wal, and only enter archive * recovery after that. * * But usually we already know how far we need to replay the WAL (up @@ -6473,7 +6473,7 @@ StartupXLOG(void) /* * Copy any missing timeline history files between 'now' and the recovery - * target timeline from archive to pg_xlog. While we don't need those + * target timeline from archive to pg_wal. While we don't need those * files ourselves - the history file of the recovery target timeline * covers all the previous timelines in the history too - a cascading * standby server might be interested in them. Or, if you archive the WAL @@ -7094,7 +7094,7 @@ StartupXLOG(void) /* * We are now done reading the xlog from stream. Turn off streaming * recovery to force fetching the files (which would be required at end of - * recovery, e.g., timeline history file) from archive or pg_xlog. + * recovery, e.g., timeline history file) from archive or pg_wal. */ StandbyMode = false; @@ -7382,7 +7382,7 @@ StartupXLOG(void) * As a compromise, we rename the last segment with the .partial * suffix, and archive it. Archive recovery will never try to read * .partial segments, so they will normally go unused. But in the odd - * PITR case, the administrator can copy them manually to the pg_xlog + * PITR case, the administrator can copy them manually to the pg_wal * directory (removing the suffix). They can be useful in debugging, * too. * @@ -9958,7 +9958,7 @@ do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p, * first WAL segment containing the startup checkpoint has pages in * the beginning with the old timeline ID. That can cause trouble at * recovery: we won't have a history file covering the old timeline if - * pg_xlog directory was not included in the base backup and the WAL + * pg_wal directory was not included in the base backup and the WAL * archive was cleared too before starting the backup. * * This also ensures that we have emitted a WAL page header that has @@ -10605,7 +10605,7 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p) * archived before returning. If archiving isn't enabled, the required WAL * needs to be transported via streaming replication (hopefully with * wal_keep_segments set high enough), or some more exotic mechanism like - * polling and copying files from pg_xlog with script. We have no + * polling and copying files from pg_wal with script. We have no * knowledge of those mechanisms, so it's up to the user to ensure that he * gets all the required WAL. * @@ -11195,9 +11195,9 @@ next_record_is_invalid: * Open the WAL segment containing WAL position 'RecPtr'. * * The segment can be fetched via restore_command, or via walreceiver having - * streamed the record, or it can already be present in pg_xlog. Checking - * pg_xlog is mainly for crash recovery, but it will be polled in standby mode - * too, in case someone copies a new segment directly to pg_xlog. That is not + * streamed the record, or it can already be present in pg_wal. Checking + * pg_wal is mainly for crash recovery, but it will be polled in standby mode + * too, in case someone copies a new segment directly to pg_wal. That is not * documented or recommended, though. * * If 'fetching_ckpt' is true, we're fetching a checkpoint record, and should @@ -11227,8 +11227,8 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, /*------- * Standby mode is implemented by a state machine: * - * 1. Read from either archive or pg_xlog (XLOG_FROM_ARCHIVE), or just - * pg_xlog (XLOG_FROM_XLOG) + * 1. Read from either archive or pg_wal (XLOG_FROM_ARCHIVE), or just + * pg_wal (XLOG_FROM_PG_WAL) * 2. Check trigger file * 3. Read from primary server via walreceiver (XLOG_FROM_STREAM) * 4. Rescan timelines @@ -11244,7 +11244,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, *------- */ if (!InArchiveRecovery) - currentSource = XLOG_FROM_PG_XLOG; + currentSource = XLOG_FROM_PG_WAL; else if (currentSource == 0) currentSource = XLOG_FROM_ARCHIVE; @@ -11263,13 +11263,13 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, switch (currentSource) { case XLOG_FROM_ARCHIVE: - case XLOG_FROM_PG_XLOG: + case XLOG_FROM_PG_WAL: /* * Check to see if the trigger file exists. Note that we * do this only after failure, so when you create the * trigger file, we still finish replaying as much as we - * can from archive and pg_xlog before failover. + * can from archive and pg_wal before failover. */ if (StandbyMode && CheckForStandbyTrigger()) { @@ -11279,7 +11279,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, /* * Not in standby mode, and we've now tried the archive - * and pg_xlog. + * and pg_wal. */ if (!StandbyMode) return false; @@ -11339,7 +11339,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, * little chance that the problem will just go away, but * PANIC is not good for availability either, especially * in hot standby mode. So, we treat that the same as - * disconnection, and retry from archive/pg_xlog again. + * disconnection, and retry from archive/pg_wal again. * The WAL in the archive should be identical to what was * streamed, so it's unlikely that it helps, but one can * hope... @@ -11400,11 +11400,11 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, elog(ERROR, "unexpected WAL source %d", currentSource); } } - else if (currentSource == XLOG_FROM_PG_XLOG) + else if (currentSource == XLOG_FROM_PG_WAL) { /* - * We just successfully read a file in pg_xlog. We prefer files in - * the archive over ones in pg_xlog, so try the next file again + * We just successfully read a file in pg_wal. We prefer files in + * the archive over ones in pg_wal, so try the next file again * from the archive first. */ if (InArchiveRecovery) @@ -11425,7 +11425,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, switch (currentSource) { case XLOG_FROM_ARCHIVE: - case XLOG_FROM_PG_XLOG: + case XLOG_FROM_PG_WAL: /* Close any old file we might have open. */ if (readFile >= 0) { @@ -11438,7 +11438,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, /* * Try to restore the file from archive, or read an existing - * file from pg_xlog. + * file from pg_wal. */ readFile = XLogFileReadAnyTLI(readSegNo, DEBUG2, currentSource == XLOG_FROM_ARCHIVE ? XLOG_FROM_ANY : @@ -11447,7 +11447,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, return true; /* success! */ /* - * Nope, not found in archive or pg_xlog. + * Nope, not found in archive or pg_wal. */ lastSourceFailed = true; break; @@ -11503,7 +11503,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, * not open already. Also read the timeline history * file if we haven't initialized timeline history * yet; it should be streamed over and present in - * pg_xlog by now. Use XLOG_FROM_STREAM so that + * pg_wal by now. Use XLOG_FROM_STREAM so that * source info is set correctly and XLogReceiptTime * isn't changed. */ @@ -11535,10 +11535,10 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, /* * Note that we don't "return false" immediately here. * After being triggered, we still want to replay all - * the WAL that was already streamed. It's in pg_xlog + * the WAL that was already streamed. It's in pg_wal * now, so we just treat this as a failure, and the * state machine will move on to replay the streamed - * WAL from pg_xlog, and then recheck the trigger and + * WAL from pg_wal, and then recheck the trigger and * exit replay. */ lastSourceFailed = true; @@ -11578,7 +11578,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, * or legitimate end-of-WAL situation. Generally, we use it as-is, but if * we're retrying the exact same record that we've tried previously, only * complain the first time to keep the noise down. However, we only do when - * reading from pg_xlog, because we don't expect any invalid records in archive + * reading from pg_wal, because we don't expect any invalid records in archive * or in records streamed from master. Files in the archive should be complete, * and we should never hit the end of WAL because we stop and wait for more WAL * to arrive before replaying it. @@ -11593,7 +11593,7 @@ emode_for_corrupt_record(int emode, XLogRecPtr RecPtr) { static XLogRecPtr lastComplaint = 0; - if (readSource == XLOG_FROM_PG_XLOG && emode == LOG) + if (readSource == XLOG_FROM_PG_WAL && emode == LOG) { if (RecPtr == lastComplaint) emode = DEBUG1; diff --git a/src/backend/access/transam/xlogarchive.c b/src/backend/access/transam/xlogarchive.c index d153a44ea9a..b919164bcbd 100644 --- a/src/backend/access/transam/xlogarchive.c +++ b/src/backend/access/transam/xlogarchive.c @@ -421,7 +421,7 @@ ExecuteRecoveryCommand(char *command, char *commandName, bool failOnSignal) /* * A file was restored from the archive under a temporary filename (path), * and now we want to keep it. Rename it under the permanent filename in - * in pg_xlog (xlogfname), replacing any existing file with the same name. + * in pg_wal (xlogfname), replacing any existing file with the same name. */ void KeepFileRestoredFromArchive(char *path, char *xlogfname) diff --git a/src/backend/access/transam/xlogfuncs.c b/src/backend/access/transam/xlogfuncs.c index 33383b4dccb..01cbd90f40a 100644 --- a/src/backend/access/transam/xlogfuncs.c +++ b/src/backend/access/transam/xlogfuncs.c @@ -128,7 +128,7 @@ pg_start_backup(PG_FUNCTION_ARGS) * pg_stop_backup: finish taking an on-line backup dump * * We write an end-of-backup WAL record, and remove the backup label file - * created by pg_start_backup, creating a backup history file in pg_xlog + * created by pg_start_backup, creating a backup history file in pg_wal * instead (whence it will immediately be archived). The backup history file * contains the same info found in the label file, plus the backup-end time * and WAL location. Before 9.0, the backup-end time was read from the backup diff --git a/src/backend/replication/README b/src/backend/replication/README index ad4864dbbeb..0cbb9906135 100644 --- a/src/backend/replication/README +++ b/src/backend/replication/README @@ -54,7 +54,7 @@ and WalRcvData->slotname, and initializes the starting point in WalRcvData->receiveStart. As walreceiver receives WAL from the master server, and writes and flushes -it to disk (in pg_xlog), it updates WalRcvData->receivedUpto and signals +it to disk (in pg_wal), it updates WalRcvData->receivedUpto and signals the startup process to know how far WAL replay can advance. Walreceiver sends information about replication progress to the master server diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c index fa75930c9f8..ffc7e586dba 100644 --- a/src/backend/replication/basebackup.c +++ b/src/backend/replication/basebackup.c @@ -346,7 +346,7 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir) TimeLineID tli; /* - * I'd rather not worry about timelines here, so scan pg_xlog and + * I'd rather not worry about timelines here, so scan pg_wal and * include all WAL files in the range between 'startptr' and 'endptr', * regardless of the timeline the file is stamped with. If there are * some spurious WAL files belonging to timelines that don't belong in @@ -359,11 +359,11 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir) XLByteToPrevSeg(endptr, endsegno); XLogFileName(lastoff, ThisTimeLineID, endsegno); - dir = AllocateDir("pg_xlog"); + dir = AllocateDir("pg_wal"); if (!dir) ereport(ERROR, - (errmsg("could not open directory \"%s\": %m", "pg_xlog"))); - while ((de = ReadDir(dir, "pg_xlog")) != NULL) + (errmsg("could not open directory \"%s\": %m", "pg_wal"))); + while ((de = ReadDir(dir, "pg_wal")) != NULL) { /* Does it look like a WAL segment, and is it in the range? */ if (IsXLogFileName(de->d_name) && @@ -401,7 +401,7 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir) qsort(walFiles, nWalFiles, sizeof(char *), compareWalFileNames); /* - * There must be at least one xlog file in the pg_xlog directory, + * There must be at least one xlog file in the pg_wal directory, * since we are doing backup-including-xlog. */ if (nWalFiles < 1) @@ -1054,23 +1054,23 @@ sendDir(char *path, int basepathlen, bool sizeonly, List *tablespaces, } /* - * We can skip pg_xlog, the WAL segments need to be fetched from the + * We can skip pg_wal, the WAL segments need to be fetched from the * WAL archive anyway. But include it as an empty directory anyway, so * we get permissions right. */ - if (strcmp(pathbuf, "./pg_xlog") == 0) + if (strcmp(pathbuf, "./pg_wal") == 0) { - /* If pg_xlog is a symlink, write it as a directory anyway */ + /* If pg_wal is a symlink, write it as a directory anyway */ size += _tarWriteDir(pathbuf, basepathlen, &statbuf, sizeonly); /* * Also send archive_status directory (by hackishly reusing * statbuf from above ...). */ - size += _tarWriteHeader("./pg_xlog/archive_status", NULL, &statbuf, + size += _tarWriteHeader("./pg_wal/archive_status", NULL, &statbuf, sizeonly); - continue; /* don't recurse into pg_xlog */ + continue; /* don't recurse into pg_wal */ } /* Allow symbolic links in pg_tblspc only */ diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c index eed6effeeb3..2bb3dce1b1c 100644 --- a/src/backend/replication/walreceiver.c +++ b/src/backend/replication/walreceiver.c @@ -18,7 +18,7 @@ * If the primary server ends streaming, but doesn't disconnect, walreceiver * goes into "waiting" mode, and waits for the startup process to give new * instructions. The startup process will treat that the same as - * disconnection, and will rescan the archive/pg_xlog directory. But when the + * disconnection, and will rescan the archive/pg_wal directory. But when the * startup process wants to try streaming replication again, it will just * nudge the existing walreceiver process that's waiting, instead of launching * a new one. @@ -365,7 +365,7 @@ WalReceiverMain(void) * we've already reached the end of the old timeline, the server will * finish the streaming immediately, and we will go back to await * orders from the startup process. If recovery_target_timeline is - * 'latest', the startup process will scan pg_xlog and find the new + * 'latest', the startup process will scan pg_wal and find the new * history file, bump recovery target timeline, and ask us to restart * on the new timeline. */ @@ -742,7 +742,7 @@ WalRcvFetchTimeLineHistoryFiles(TimeLineID first, TimeLineID last) tli))); /* - * Write the file to pg_xlog. + * Write the file to pg_wal. */ writeTimeLineHistoryFile(tli, content, len); diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index 0f3ced250cd..bc5e50807af 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -586,7 +586,7 @@ StartReplication(StartReplicationCmd *cmd) * segment that contains switchpoint, but on the new timeline, so * that it doesn't end up with a partial segment. If you ask for a * too old starting point, you'll get an error later when we fail - * to find the requested WAL segment in pg_xlog. + * to find the requested WAL segment in pg_wal. * * XXX: we could be more strict here and only allow a startpoint * that's older than the switchpoint, if it's still in the same @@ -2058,7 +2058,7 @@ retry: * * For example, imagine that this server is currently on timeline * 5, and we're streaming timeline 4. The switch from timeline 4 - * to 5 happened at 0/13002088. In pg_xlog, we have these files: + * to 5 happened at 0/13002088. In pg_wal, we have these files: * * ... * 000000040000000000000012 diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index 03143f11334..b7ff5efe021 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -2787,7 +2787,7 @@ looks_like_temp_rel_name(const char *name) * Issue fsync recursively on PGDATA and all its contents. * * We fsync regular files and directories wherever they are, but we - * follow symlinks only for pg_xlog and immediately under pg_tblspc. + * follow symlinks only for pg_wal and immediately under pg_tblspc. * Other symlinks are presumed to point at files we're not responsible * for fsyncing, and might not have privileges to write at all. * @@ -2811,7 +2811,7 @@ SyncDataDirectory(void) return; /* - * If pg_xlog is a symlink, we'll need to recurse into it separately, + * If pg_wal is a symlink, we'll need to recurse into it separately, * because the first walkdir below will ignore it. */ xlog_is_symlink = false; @@ -2820,16 +2820,16 @@ SyncDataDirectory(void) { struct stat st; - if (lstat("pg_xlog", &st) < 0) + if (lstat("pg_wal", &st) < 0) ereport(LOG, (errcode_for_file_access(), errmsg("could not stat file \"%s\": %m", - "pg_xlog"))); + "pg_wal"))); else if (S_ISLNK(st.st_mode)) xlog_is_symlink = true; } #else - if (pgwin32_is_junction("pg_xlog")) + if (pgwin32_is_junction("pg_wal")) xlog_is_symlink = true; #endif @@ -2841,7 +2841,7 @@ SyncDataDirectory(void) #ifdef PG_FLUSH_DATA_WORKS walkdir(".", pre_sync_fname, false, DEBUG1); if (xlog_is_symlink) - walkdir("pg_xlog", pre_sync_fname, false, DEBUG1); + walkdir("pg_wal", pre_sync_fname, false, DEBUG1); walkdir("pg_tblspc", pre_sync_fname, true, DEBUG1); #endif @@ -2849,14 +2849,14 @@ SyncDataDirectory(void) * Now we do the fsync()s in the same order. * * The main call ignores symlinks, so in addition to specially processing - * pg_xlog if it's a symlink, pg_tblspc has to be visited separately with + * pg_wal if it's a symlink, pg_tblspc has to be visited separately with * process_symlinks = true. Note that if there are any plain directories * in pg_tblspc, they'll get fsync'd twice. That's not an expected case * so we don't worry about optimizing it. */ walkdir(".", datadir_fsync_fname, false, LOG); if (xlog_is_symlink) - walkdir("pg_xlog", datadir_fsync_fname, false, LOG); + walkdir("pg_wal", datadir_fsync_fname, false, LOG); walkdir("pg_tblspc", datadir_fsync_fname, true, LOG); } diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 9e23f641308..c8a8c52c3d7 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -195,7 +195,7 @@ static const char *backend_options = "--single -F -O -j -c search_path=pg_catalo static const char *const subdirs[] = { "global", - "pg_xlog/archive_status", + "pg_wal/archive_status", "pg_clog", "pg_commit_ts", "pg_dynshmem", @@ -2091,8 +2091,6 @@ make_postgres(FILE *cmdfd) PG_CMD_PUTS(*line); } - - /* * signal handler in case we are interrupted. * @@ -2830,7 +2828,7 @@ create_xlog_or_symlink(void) char *subdirloc; /* form name of the place for the subdirectory or symlink */ - subdirloc = psprintf("%s/pg_xlog", pg_data); + subdirloc = psprintf("%s/pg_wal", pg_data); if (strcmp(xlog_dir, "") != 0) { @@ -2963,7 +2961,7 @@ initialize_data_directory(void) create_xlog_or_symlink(); - /* Create required subdirectories (other than pg_xlog) */ + /* Create required subdirectories (other than pg_wal) */ printf(_("creating subdirectories ... ")); fflush(stdout); @@ -3260,7 +3258,7 @@ main(int argc, char *argv[]) fputs(_("syncing data to disk ... "), stdout); fflush(stdout); - fsync_pgdata(pg_data, progname); + fsync_pgdata(pg_data, progname, PG_VERSION_NUM); check_ok(); return 0; } @@ -3326,7 +3324,7 @@ main(int argc, char *argv[]) { fputs(_("syncing data to disk ... "), stdout); fflush(stdout); - fsync_pgdata(pg_data, progname); + fsync_pgdata(pg_data, progname, PG_VERSION_NUM); check_ok(); } else diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index 76e8f449fea..b82b8e1b263 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -55,6 +55,12 @@ typedef struct TablespaceList TablespaceListCell *tail; } TablespaceList; +/* + * pg_xlog has been renamed to pg_wal in version 10. This version number + * should be compared with PQserverVersion(). + */ +#define MINIMUM_VERSION_FOR_PG_WAL 100000 + /* Global options */ static char *basedir = NULL; static TablespaceList tablespace_dirs = {NULL, NULL}; @@ -526,15 +532,22 @@ StartLogStreamer(char *startpos, uint32 timeline, char *sysidentifier) /* Error message already written in GetConnection() */ exit(1); - snprintf(param->xlogdir, sizeof(param->xlogdir), "%s/pg_xlog", basedir); + /* In post-10 cluster, pg_xlog has been renamed to pg_wal */ + snprintf(param->xlogdir, sizeof(param->xlogdir), "%s/%s", + basedir, + PQserverVersion(conn) < MINIMUM_VERSION_FOR_PG_WAL ? + "pg_xlog" : "pg_wal"); /* - * Create pg_xlog/archive_status (and thus pg_xlog) so we can write to - * basedir/pg_xlog as the directory entry in the tar file may arrive - * later. + * Create pg_wal/archive_status or pg_xlog/archive_status (and thus + * pg_wal or pg_xlog) depending on the target server so we can write to + * basedir/pg_wal or basedir/pg_xlog as the directory entry in the tar + * file may arrive later. */ - snprintf(statusdir, sizeof(statusdir), "%s/pg_xlog/archive_status", - basedir); + snprintf(statusdir, sizeof(statusdir), "%s/%s/archive_status", + basedir, + PQserverVersion(conn) < MINIMUM_VERSION_FOR_PG_WAL ? + "pg_xlog" : "pg_wal"); if (pg_mkdir_p(statusdir, S_IRWXU) != 0 && errno != EEXIST) { @@ -1338,15 +1351,17 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum) if (mkdir(filename, S_IRWXU) != 0) { /* - * When streaming WAL, pg_xlog will have been created - * by the wal receiver process. Also, when transaction - * log directory location was specified, pg_xlog has - * already been created as a symbolic link before - * starting the actual backup. So just ignore creation - * failures on related directories. + * When streaming WAL, pg_wal (or pg_xlog for pre-9.6 + * clusters) will have been created by the wal receiver + * process. Also, when transaction log directory location + * was specified, pg_wal (or pg_xlog) has already been + * created as a symbolic link before starting the actual + * backup. So just ignore creation failures on related + * directories. */ - if (!((pg_str_endswith(filename, "/pg_xlog") || - pg_str_endswith(filename, "/archive_status")) && + if (!((pg_str_endswith(filename, "/pg_wal") || + pg_str_endswith(filename, "/pg_xlog")|| + pg_str_endswith(filename, "/archive_status")) && errno == EEXIST)) { fprintf(stderr, @@ -1634,15 +1649,10 @@ BaseBackup(void) char xlogend[64]; int minServerMajor, maxServerMajor; - int serverMajor; + int serverVersion, + serverMajor; - /* - * Connect in replication mode to the server - */ - conn = GetConnection(); - if (!conn) - /* Error message already written in GetConnection() */ - exit(1); + Assert(conn != NULL); /* * Check server version. BASE_BACKUP command was introduced in 9.1, so we @@ -1650,7 +1660,8 @@ BaseBackup(void) */ minServerMajor = 901; maxServerMajor = PG_VERSION_NUM / 100; - serverMajor = PQserverVersion(conn) / 100; + serverVersion = PQserverVersion(conn); + serverMajor = serverVersion / 100; if (serverMajor < minServerMajor || serverMajor > maxServerMajor) { const char *serverver = PQparameterStatus(conn, "server_version"); @@ -1979,7 +1990,7 @@ BaseBackup(void) } else { - (void) fsync_pgdata(basedir, progname); + (void) fsync_pgdata(basedir, progname, serverVersion); } } @@ -2296,6 +2307,14 @@ main(int argc, char **argv) if (format == 'p' || strcmp(basedir, "-") != 0) verify_dir_is_empty_or_create(basedir, &made_new_pgdata, &found_existing_pgdata); + /* connection in replication mode to server */ + conn = GetConnection(); + if (!conn) + { + /* Error message already written in GetConnection() */ + exit(1); + } + /* Create transaction log symlink, if required */ if (strcmp(xlog_dir, "") != 0) { @@ -2303,19 +2322,24 @@ main(int argc, char **argv) verify_dir_is_empty_or_create(xlog_dir, &made_new_xlogdir, &found_existing_xlogdir); - /* form name of the place where the symlink must go */ - linkloc = psprintf("%s/pg_xlog", basedir); + /* + * Form name of the place where the symlink must go. pg_xlog has + * been renamed to pg_wal in post-10 clusters. + */ + linkloc = psprintf("%s/%s", basedir, + PQserverVersion(conn) < MINIMUM_VERSION_FOR_PG_WAL ? + "pg_xlog" : "pg_wal"); #ifdef HAVE_SYMLINK if (symlink(xlog_dir, linkloc) != 0) { fprintf(stderr, _("%s: could not create symbolic link \"%s\": %s\n"), progname, linkloc, strerror(errno)); - exit(1); + disconnect_and_exit(1); } #else fprintf(stderr, _("%s: symlinks are not supported on this platform\n")); - exit(1); + disconnect_and_exit(1); #endif free(linkloc); } diff --git a/src/bin/pg_basebackup/t/010_pg_basebackup.pl b/src/bin/pg_basebackup/t/010_pg_basebackup.pl index fcedfed2b23..579d7a15fbf 100644 --- a/src/bin/pg_basebackup/t/010_pg_basebackup.pl +++ b/src/bin/pg_basebackup/t/010_pg_basebackup.pl @@ -67,9 +67,9 @@ $node->command_ok([ 'pg_basebackup', '-D', "$tempdir/backup" ], 'pg_basebackup runs'); ok(-f "$tempdir/backup/PG_VERSION", 'backup was created'); -# Only archive_status directory should be copied in pg_xlog/. +# Only archive_status directory should be copied in pg_wal/. is_deeply( - [ sort(slurp_dir("$tempdir/backup/pg_xlog/")) ], + [ sort(slurp_dir("$tempdir/backup/pg_wal/")) ], [ sort qw(. .. archive_status) ], 'no WAL files copied'); @@ -230,12 +230,12 @@ like( $node->command_ok( [ 'pg_basebackup', '-D', "$tempdir/backupxf", '-X', 'fetch' ], 'pg_basebackup -X fetch runs'); -ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxf/pg_xlog")), +ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxf/pg_wal")), 'WAL files copied'); $node->command_ok( [ 'pg_basebackup', '-D', "$tempdir/backupxs", '-X', 'stream' ], 'pg_basebackup -X stream runs'); -ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxf/pg_xlog")), +ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxf/pg_wal")), 'WAL files copied'); $node->command_fails( diff --git a/src/bin/pg_resetxlog/pg_resetxlog.c b/src/bin/pg_resetxlog/pg_resetxlog.c index 525b82ba7a7..2b76f640797 100644 --- a/src/bin/pg_resetxlog/pg_resetxlog.c +++ b/src/bin/pg_resetxlog/pg_resetxlog.c @@ -890,7 +890,7 @@ FindEndOfXLOG(void) newXlogSegNo = ControlFile.checkPointCopy.redo / ControlFile.xlog_seg_size; /* - * Scan the pg_xlog directory to find existing WAL segment files. We + * Scan the pg_wal directory to find existing WAL segment files. We * assume any present have been used; in most scenarios this should be * conservative, because of xlog.c's attempts to pre-create files. */ diff --git a/src/bin/pg_rewind/copy_fetch.c b/src/bin/pg_rewind/copy_fetch.c index 327e7ef5411..d0c1586562b 100644 --- a/src/bin/pg_rewind/copy_fetch.c +++ b/src/bin/pg_rewind/copy_fetch.c @@ -131,10 +131,10 @@ recurse_dir(const char *datadir, const char *parentpath, /* * If it's a symlink within pg_tblspc, we need to recurse into it, * to process all the tablespaces. We also follow a symlink if - * it's for pg_xlog. Symlinks elsewhere are ignored. + * it's for pg_wal. Symlinks elsewhere are ignored. */ if ((parentpath && strcmp(parentpath, "pg_tblspc") == 0) || - strcmp(path, "pg_xlog") == 0) + strcmp(path, "pg_wal") == 0) recurse_dir(datadir, path, callback); #else pg_fatal("\"%s\" is a symbolic link, but symbolic links are not supported on this platform\n", diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c index 9b00dc1cdc1..3905a5d6ce3 100644 --- a/src/bin/pg_rewind/filemap.c +++ b/src/bin/pg_rewind/filemap.c @@ -79,11 +79,11 @@ process_source_file(const char *path, file_type_t type, size_t newsize, return; /* - * Pretend that pg_xlog is a directory, even if it's really a symlink. We + * Pretend that pg_wal is a directory, even if it's really a symlink. We * don't want to mess with the symlink itself, nor complain if it's a * symlink in source but not in target or vice versa. */ - if (strcmp(path, "pg_xlog") == 0 && type == FILE_TYPE_SYMLINK) + if (strcmp(path, "pg_wal") == 0 && type == FILE_TYPE_SYMLINK) type = FILE_TYPE_DIRECTORY; /* @@ -120,7 +120,7 @@ process_source_file(const char *path, file_type_t type, size_t newsize, switch (type) { case FILE_TYPE_DIRECTORY: - if (exists && !S_ISDIR(statbuf.st_mode) && strcmp(path, "pg_xlog") != 0) + if (exists && !S_ISDIR(statbuf.st_mode) && strcmp(path, "pg_wal") != 0) { /* it's a directory in source, but not in target. Strange.. */ pg_fatal("\"%s\" is not a directory\n", localpath); @@ -296,7 +296,7 @@ process_target_file(const char *path, file_type_t type, size_t oldsize, /* * Like in process_source_file, pretend that xlog is always a directory. */ - if (strcmp(path, "pg_xlog") == 0 && type == FILE_TYPE_SYMLINK) + if (strcmp(path, "pg_wal") == 0 && type == FILE_TYPE_SYMLINK) type = FILE_TYPE_DIRECTORY; key.path = (char *) path; diff --git a/src/bin/pg_rewind/parsexlog.c b/src/bin/pg_rewind/parsexlog.c index b53591d02a1..23ac4e7bb0e 100644 --- a/src/bin/pg_rewind/parsexlog.c +++ b/src/bin/pg_rewind/parsexlog.c @@ -54,7 +54,7 @@ static int SimpleXLogPageRead(XLogReaderState *xlogreader, TimeLineID *pageTLI); /* - * Read WAL from the datadir/pg_xlog, starting from 'startpoint' on timeline + * Read WAL from the datadir/pg_wal, starting from 'startpoint' on timeline * index 'tliIndex' in target timeline history, until 'endpoint'. Make note of * the data blocks touched by the WAL records, and return them in a page map. */ diff --git a/src/bin/pg_rewind/t/004_pg_xlog_symlink.pl b/src/bin/pg_rewind/t/004_pg_xlog_symlink.pl index bdcab5688b9..12950ea1ca6 100644 --- a/src/bin/pg_rewind/t/004_pg_xlog_symlink.pl +++ b/src/bin/pg_rewind/t/004_pg_xlog_symlink.pl @@ -1,5 +1,5 @@ # -# Test pg_rewind when the target's pg_xlog directory is a symlink. +# Test pg_rewind when the target's pg_wal directory is a symlink. # use strict; use warnings; @@ -30,10 +30,10 @@ sub run_test my $test_master_datadir = $node_master->data_dir; - # turn pg_xlog into a symlink - print("moving $test_master_datadir/pg_xlog to $master_xlogdir\n"); - move("$test_master_datadir/pg_xlog", $master_xlogdir) or die; - symlink($master_xlogdir, "$test_master_datadir/pg_xlog") or die; + # turn pg_wal into a symlink + print("moving $test_master_datadir/pg_wal to $master_xlogdir\n"); + move("$test_master_datadir/pg_wal", $master_xlogdir) or die; + symlink($master_xlogdir, "$test_master_datadir/pg_wal") or die; RewindTest::start_master(); diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c index 6d04e5671db..55a6f0dfbad 100644 --- a/src/bin/pg_upgrade/exec.c +++ b/src/bin/pg_upgrade/exec.c @@ -14,7 +14,7 @@ #include <fcntl.h> #include <sys/types.h> -static void check_data_dir(const char *pg_data); +static void check_data_dir(ClusterInfo *cluster); static void check_bin_dir(ClusterInfo *cluster); static void validate_exec(const char *dir, const char *cmdName); @@ -220,9 +220,9 @@ verify_directories(void) pg_fatal("You must have read and write access in the current directory.\n"); check_bin_dir(&old_cluster); - check_data_dir(old_cluster.pgdata); + check_data_dir(&old_cluster); check_bin_dir(&new_cluster); - check_data_dir(new_cluster.pgdata); + check_data_dir(&new_cluster); } @@ -253,6 +253,32 @@ win32_check_directory_write_permissions(void) /* + * check_single_dir() + * + * Check for the presence of a single directory in PGDATA, and fail if + * is it missing or not accessible. + */ +static void +check_single_dir(const char *pg_data, const char *subdir) +{ + struct stat statBuf; + char subDirName[MAXPGPATH]; + + snprintf(subDirName, sizeof(subDirName), "%s%s%s", pg_data, + /* Win32 can't stat() a directory with a trailing slash. */ + *subdir ? "/" : "", + subdir); + + if (stat(subDirName, &statBuf) != 0) + report_status(PG_FATAL, "check for \"%s\" failed: %s\n", + subDirName, strerror(errno)); + else if (!S_ISDIR(statBuf.st_mode)) + report_status(PG_FATAL, "%s is not a directory\n", + subDirName); +} + + +/* * check_data_dir() * * This function validates the given cluster directory - we search for a @@ -262,34 +288,27 @@ win32_check_directory_write_permissions(void) * */ static void -check_data_dir(const char *pg_data) +check_data_dir(ClusterInfo *cluster) { - char subDirName[MAXPGPATH]; - int subdirnum; - - /* start check with top-most directory */ - const char *requiredSubdirs[] = {"", "base", "global", "pg_clog", - "pg_multixact", "pg_subtrans", "pg_tblspc", "pg_twophase", - "pg_xlog"}; - - for (subdirnum = 0; - subdirnum < sizeof(requiredSubdirs) / sizeof(requiredSubdirs[0]); - ++subdirnum) - { - struct stat statBuf; - - snprintf(subDirName, sizeof(subDirName), "%s%s%s", pg_data, - /* Win32 can't stat() a directory with a trailing slash. */ - *requiredSubdirs[subdirnum] ? "/" : "", - requiredSubdirs[subdirnum]); - - if (stat(subDirName, &statBuf) != 0) - report_status(PG_FATAL, "check for \"%s\" failed: %s\n", - subDirName, strerror(errno)); - else if (!S_ISDIR(statBuf.st_mode)) - report_status(PG_FATAL, "%s is not a directory\n", - subDirName); - } + const char *pg_data = cluster->pgdata; + + /* get old and new cluster versions */ + old_cluster.major_version = get_major_server_version(&old_cluster); + new_cluster.major_version = get_major_server_version(&new_cluster); + + check_single_dir(pg_data, ""); + check_single_dir(pg_data, "base"); + check_single_dir(pg_data, "global"); + check_single_dir(pg_data, "pg_multixact"); + check_single_dir(pg_data, "pg_subtrans"); + check_single_dir(pg_data, "pg_tblspc"); + check_single_dir(pg_data, "pg_twophase"); + + /* pg_xlog has been renamed to pg_wal in post-10 cluster */ + if (GET_MAJOR_VERSION(cluster->major_version) < 1000) + check_single_dir(pg_data, "pg_xlog"); + else + check_single_dir(pg_data, "pg_wal"); } diff --git a/src/bin/pg_xlogdump/pg_xlogdump.c b/src/bin/pg_xlogdump/pg_xlogdump.c index 9ad9321e1f9..74903980ae5 100644 --- a/src/bin/pg_xlogdump/pg_xlogdump.c +++ b/src/bin/pg_xlogdump/pg_xlogdump.c @@ -680,7 +680,7 @@ usage(void) printf(" -f, --follow keep retrying after reaching end of WAL\n"); printf(" -n, --limit=N number of records to display\n"); printf(" -p, --path=PATH directory in which to find log segment files\n"); - printf(" (default: ./pg_xlog)\n"); + printf(" (default: ./pg_wal)\n"); printf(" -r, --rmgr=RMGR only show records generated by resource manager RMGR\n"); printf(" use --rmgr=list to list valid resource manager names\n"); printf(" -s, --start=RECPTR start reading at log position RECPTR\n"); diff --git a/src/common/file_utils.c b/src/common/file_utils.c index 1855e2372c8..2fdb4692ea8 100644 --- a/src/common/file_utils.c +++ b/src/common/file_utils.c @@ -29,6 +29,11 @@ #define PG_FLUSH_DATA_WORKS 1 #endif +/* + * pg_xlog has been renamed to pg_wal in version 10. + */ +#define MINIMUM_VERSION_FOR_PG_WAL 100000 + #ifdef PG_FLUSH_DATA_WORKS static int pre_sync_fname(const char *fname, bool isdir, const char *progname); @@ -40,25 +45,31 @@ static void walkdir(const char *path, /* * Issue fsync recursively on PGDATA and all its contents. * - * We fsync regular files and directories wherever they are, but we - * follow symlinks only for pg_xlog and immediately under pg_tblspc. - * Other symlinks are presumed to point at files we're not responsible - * for fsyncing, and might not have privileges to write at all. + * We fsync regular files and directories wherever they are, but we follow + * symlinks only for pg_wal (or pg_xlog) and immediately under pg_tblspc. + * Other symlinks are presumed to point at files we're not responsible for + * fsyncing, and might not have privileges to write at all. + * + * serverVersion indicates the version of the server to be fsync'd. * * Errors are reported but not considered fatal. */ void -fsync_pgdata(const char *pg_data, const char *progname) +fsync_pgdata(const char *pg_data, + const char *progname, + int serverVersion) { bool xlog_is_symlink; - char pg_xlog[MAXPGPATH]; + char pg_wal[MAXPGPATH]; char pg_tblspc[MAXPGPATH]; - snprintf(pg_xlog, MAXPGPATH, "%s/pg_xlog", pg_data); + /* handle renaming of pg_xlog to pg_wal in post-10 clusters */ + snprintf(pg_wal, MAXPGPATH, "%s/%s", pg_data, + serverVersion < MINIMUM_VERSION_FOR_PG_WAL ? "pg_xlog" : "pg_wal"); snprintf(pg_tblspc, MAXPGPATH, "%s/pg_tblspc", pg_data); /* - * If pg_xlog is a symlink, we'll need to recurse into it separately, + * If pg_wal is a symlink, we'll need to recurse into it separately, * because the first walkdir below will ignore it. */ xlog_is_symlink = false; @@ -67,14 +78,14 @@ fsync_pgdata(const char *pg_data, const char *progname) { struct stat st; - if (lstat(pg_xlog, &st) < 0) + if (lstat(pg_wal, &st) < 0) fprintf(stderr, _("%s: could not stat file \"%s\": %s\n"), - progname, pg_xlog, strerror(errno)); + progname, pg_wal, strerror(errno)); else if (S_ISLNK(st.st_mode)) xlog_is_symlink = true; } #else - if (pgwin32_is_junction(pg_xlog)) + if (pgwin32_is_junction(pg_wal)) xlog_is_symlink = true; #endif @@ -85,7 +96,7 @@ fsync_pgdata(const char *pg_data, const char *progname) #ifdef PG_FLUSH_DATA_WORKS walkdir(pg_data, pre_sync_fname, false, progname); if (xlog_is_symlink) - walkdir(pg_xlog, pre_sync_fname, false, progname); + walkdir(pg_wal, pre_sync_fname, false, progname); walkdir(pg_tblspc, pre_sync_fname, true, progname); #endif @@ -93,14 +104,14 @@ fsync_pgdata(const char *pg_data, const char *progname) * Now we do the fsync()s in the same order. * * The main call ignores symlinks, so in addition to specially processing - * pg_xlog if it's a symlink, pg_tblspc has to be visited separately with + * pg_wal if it's a symlink, pg_tblspc has to be visited separately with * process_symlinks = true. Note that if there are any plain directories * in pg_tblspc, they'll get fsync'd twice. That's not an expected case * so we don't worry about optimizing it. */ walkdir(pg_data, fsync_fname, false, progname); if (xlog_is_symlink) - walkdir(pg_xlog, fsync_fname, false, progname); + walkdir(pg_wal, fsync_fname, false, progname); walkdir(pg_tblspc, fsync_fname, true, progname); } diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 0a595ccc481..ceb0462098a 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -128,7 +128,7 @@ typedef XLogLongPageHeaderData *XLogLongPageHeader; /* * The XLog directory and control file (relative to $PGDATA) */ -#define XLOGDIR "pg_xlog" +#define XLOGDIR "pg_wal" #define XLOG_CONTROL_FILE "global/pg_control" /* diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index bfa6b870a10..cd3048db868 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 201610121 +#define CATALOG_VERSION_NO 201610201 #endif diff --git a/src/include/common/file_utils.h b/src/include/common/file_utils.h index 1cb263d9e20..b83c398235c 100644 --- a/src/include/common/file_utils.h +++ b/src/include/common/file_utils.h @@ -17,7 +17,8 @@ extern int fsync_fname(const char *fname, bool isdir, const char *progname); -extern void fsync_pgdata(const char *pg_data, const char *progname); +extern void fsync_pgdata(const char *pg_data, const char *progname, + int serverVersion); extern int durable_rename(const char *oldfile, const char *newfile, const char *progname); extern int fsync_parent_path(const char *fname, const char *progname); diff --git a/src/include/postmaster/pgarch.h b/src/include/postmaster/pgarch.h index f2cbfb3952a..6df73c946df 100644 --- a/src/include/postmaster/pgarch.h +++ b/src/include/postmaster/pgarch.h @@ -16,7 +16,7 @@ /* ---------- * Archiver control info. * - * We expect that archivable files within pg_xlog will have names between + * We expect that archivable files within pg_wal will have names between * MIN_XFN_CHARS and MAX_XFN_CHARS in length, consisting only of characters * appearing in VALID_XFN_CHARS. The status files in archive_status have * corresponding names with ".ready" or ".done" appended. |