]> granicus.if.org Git - postgresql/commitdiff
Improve log messages related to tablespace_map file
authorFujii Masao <fujii@postgresql.org>
Tue, 15 Sep 2015 14:21:51 +0000 (23:21 +0900)
committerFujii Masao <fujii@postgresql.org>
Tue, 15 Sep 2015 14:21:51 +0000 (23:21 +0900)
This patch changes the log message which is logged when the server
successfully renames backup_label file to *.old but fails to rename
tablespace_map file during the shutdown. Previously the WARNING
message "online backup mode was not canceled" was logged in that case.
However this message is confusing because the backup mode is treated
as canceled whenever backup_label is successfully renamed. So this
commit makes the server log the message "online backup mode canceled"
in that case.

Also this commit changes errdetail messages so that they follow the
error message style guide.

Back-patch to 9.5 where tablespace_map file is introduced.

Original patch by Amit Kapila, heavily modified by me.

src/backend/access/transam/xlog.c

index 152d4ede37a51ad29984c9a7a6f5b7f2017555cf..a092aad2d30932c7b7575a6bec45018c122f5c09 100644 (file)
@@ -6160,13 +6160,13 @@ StartupXLOG(void)
                                ereport(LOG,
                                        (errmsg("ignoring \"%s\" file because no \"%s\" file exists",
                                                        TABLESPACE_MAP, BACKUP_LABEL_FILE),
-                                        errdetail("\"%s\" was renamed to \"%s\".",
+                                        errdetail("File \"%s\" was renamed to \"%s\".",
                                                           TABLESPACE_MAP, TABLESPACE_MAP_OLD)));
                        else
                                ereport(LOG,
                                                (errmsg("ignoring \"%s\" file because no \"%s\" file exists",
                                                                TABLESPACE_MAP, BACKUP_LABEL_FILE),
-                                                errdetail("Could not rename file \"%s\" to \"%s\": %m.",
+                                                errdetail("File \"%s\" could not be renamed to \"%s\": %m.",
                                                                   TABLESPACE_MAP, TABLESPACE_MAP_OLD)));
                }
 
@@ -10911,32 +10911,32 @@ CancelBackup(void)
 {
        struct stat stat_buf;
 
-       /* if the file is not there, return */
+       /* if the backup_label file is not there, return */
        if (stat(BACKUP_LABEL_FILE, &stat_buf) < 0)
                return;
 
        /* remove leftover file from previously canceled backup if it exists */
        unlink(BACKUP_LABEL_OLD);
 
-       if (rename(BACKUP_LABEL_FILE, BACKUP_LABEL_OLD) == 0)
-       {
-               ereport(LOG,
-                               (errmsg("online backup mode canceled"),
-                                errdetail("\"%s\" was renamed to \"%s\".",
-                                                  BACKUP_LABEL_FILE, BACKUP_LABEL_OLD)));
-       }
-       else
+       if (rename(BACKUP_LABEL_FILE, BACKUP_LABEL_OLD) != 0)
        {
                ereport(WARNING,
                                (errcode_for_file_access(),
                                 errmsg("online backup mode was not canceled"),
-                                errdetail("Could not rename \"%s\" to \"%s\": %m.",
+                                errdetail("File \"%s\" could not be renamed to \"%s\": %m.",
                                                   BACKUP_LABEL_FILE, BACKUP_LABEL_OLD)));
+               return;
        }
 
        /* if the tablespace_map file is not there, return */
        if (stat(TABLESPACE_MAP, &stat_buf) < 0)
+       {
+               ereport(LOG,
+                               (errmsg("online backup mode canceled"),
+                                errdetail("File \"%s\" was renamed to \"%s\".",
+                                                  BACKUP_LABEL_FILE, BACKUP_LABEL_OLD)));
                return;
+       }
 
        /* remove leftover file from previously canceled backup if it exists */
        unlink(TABLESPACE_MAP_OLD);
@@ -10945,15 +10945,19 @@ CancelBackup(void)
        {
                ereport(LOG,
                                (errmsg("online backup mode canceled"),
-                                errdetail("\"%s\" was renamed to \"%s\".",
-                                                  TABLESPACE_MAP, TABLESPACE_MAP_OLD)));
+                                errdetail("Files \"%s\" and \"%s\" were renamed to "
+                                                  "\"%s\" and \"%s\", respectively.",
+                                                  BACKUP_LABEL_FILE, TABLESPACE_MAP,
+                                                  BACKUP_LABEL_OLD, TABLESPACE_MAP_OLD)));
        }
        else
        {
                ereport(WARNING,
                                (errcode_for_file_access(),
-                                errmsg("online backup mode was not canceled"),
-                                errdetail("Could not rename \"%s\" to \"%s\": %m.",
+                                errmsg("online backup mode canceled"),
+                                errdetail("File \"%s\" was renamed to \"%s\", but "
+                                                  "file \"%s\" could not be renamed to \"%s\": %m.",
+                                                  BACKUP_LABEL_FILE, BACKUP_LABEL_OLD,
                                                   TABLESPACE_MAP, TABLESPACE_MAP_OLD)));
        }
 }