aboutsummaryrefslogtreecommitdiff
path: root/src/common/file_utils.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2016-10-20 11:24:37 -0400
committerRobert Haas <rhaas@postgresql.org>2016-10-20 11:32:18 -0400
commitf82ec32ac30ae7e3ec7c84067192535b2ff8ec0e (patch)
tree929d4709a42149a4bbde12edad16183a96bcef6a /src/common/file_utils.c
parentec7db2b483e0ff247ed41612cdb5716022401fe6 (diff)
downloadpostgresql-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/common/file_utils.c')
-rw-r--r--src/common/file_utils.c39
1 files changed, 25 insertions, 14 deletions
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);
}