diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 150d56a..d66f9a8 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -5882,6 +5882,7 @@ StartupXLOG(void) XLogReaderState *xlogreader; XLogPageReadPrivate private; bool fast_promoted = false; + struct stat st; /* * Read control file and check XLOG status looks valid. @@ -6074,7 +6075,6 @@ StartupXLOG(void) if (read_tablespace_map(&tablespaces)) { ListCell *lc; - struct stat st; foreach(lc, tablespaces) { @@ -6128,6 +6128,22 @@ StartupXLOG(void) else { /* + * If tablespace_map file is present without backup_label file, there + * is no use of such file. There is no harm in retaining it, but it + * is better to get rid of the map file so that we don't have any + * redundant file in data directory and it will avoid any sort of + * confusion. It seems prudent though to just rename the file out + * of the way rather than delete it completely, also we ignore any + * error that occurs in rename operation as even if map file is + * present without backup_label file, it is harmless. + */ + if (stat(TABLESPACE_MAP, &st) == 0) + { + unlink(TABLESPACE_MAP_OLD); + rename(TABLESPACE_MAP, TABLESPACE_MAP_OLD); + } + + /* * It's possible that archive recovery was requested, but we don't * know how far we need to replay the WAL before we reach consistency. * This can happen for example if a base backup is taken from a