aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/time/snapmgr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/time/snapmgr.c')
-rw-r--r--src/backend/utils/time/snapmgr.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index addf87dc3bb..0b032905a5e 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1619,27 +1619,25 @@ DeleteAllExportedSnapshotFiles(void)
DIR *s_dir;
struct dirent *s_de;
- if (!(s_dir = AllocateDir(SNAPSHOT_EXPORT_DIR)))
- {
- /*
- * We really should have that directory in a sane cluster setup. But
- * then again if we don't, it's not fatal enough to make it FATAL.
- * Since we're running in the postmaster, LOG is our best bet.
- */
- elog(LOG, "could not open directory \"%s\": %m", SNAPSHOT_EXPORT_DIR);
- return;
- }
+ /*
+ * Problems in reading the directory, or unlinking files, are reported at
+ * LOG level. Since we're running in the startup process, ERROR level
+ * would prevent database start, and it's not important enough for that.
+ */
+ s_dir = AllocateDir(SNAPSHOT_EXPORT_DIR);
- while ((s_de = ReadDir(s_dir, SNAPSHOT_EXPORT_DIR)) != NULL)
+ while ((s_de = ReadDirExtended(s_dir, SNAPSHOT_EXPORT_DIR, LOG)) != NULL)
{
if (strcmp(s_de->d_name, ".") == 0 ||
strcmp(s_de->d_name, "..") == 0)
continue;
snprintf(buf, sizeof(buf), SNAPSHOT_EXPORT_DIR "/%s", s_de->d_name);
- /* Again, unlink failure is not worthy of FATAL */
- if (unlink(buf))
- elog(LOG, "could not unlink file \"%s\": %m", buf);
+
+ if (unlink(buf) != 0)
+ ereport(LOG,
+ (errcode_for_file_access(),
+ errmsg("could not remove file \"%s\": %m", buf)));
}
FreeDir(s_dir);