Error out in pg_rewind if lstat() fails.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 15 Apr 2015 20:13:32 +0000 (23:13 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 15 Apr 2015 20:13:32 +0000 (23:13 +0300)
A "file not found" is expected if the source server is running, so don't
complain about that. But any other error is definitely not expected.

src/bin/pg_rewind/copy_fetch.c

index 887fec9c9d0ae4172f70b83970d3388393cb63ca..397bf204f941415e7030d7304a9594d3c78e364b 100644 (file)
@@ -75,17 +75,20 @@ recurse_dir(const char *datadir, const char *parentpath,
 
        if (lstat(fullpath, &fst) < 0)
        {
-           pg_log(PG_WARNING, "could not stat file \"%s\": %s",
-                  fullpath, strerror(errno));
-
-           /*
-            * This is ok, if the new master is running and the file was just
-            * removed. If it was a data file, there should be a WAL record of
-            * the removal. If it was something else, it couldn't have been
-            * critical anyway.
-            *
-            * TODO: But complain if we're processing the target dir!
-            */
+           if (errno == ENOENT)
+           {
+               /*
+                * File doesn't exist anymore. This is ok, if the new master
+                * is running and the file was just removed. If it was a data
+                * file, there should be a WAL record of the removal. If it
+                * was something else, it couldn't have been anyway.
+                *
+                * TODO: But complain if we're processing the target dir!
+                */
+           }
+           else
+               pg_fatal("could not stat file \"%s\": %s",
+                        fullpath, strerror(errno));
        }
 
        if (parentpath)