]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
basic_archive: Allow archive directory to be missing at startup.
authorNathan Bossart <nathan@postgresql.org>
Mon, 2 Mar 2026 19:12:25 +0000 (13:12 -0600)
committerNathan Bossart <nathan@postgresql.org>
Mon, 2 Mar 2026 19:12:25 +0000 (13:12 -0600)
Presently, the GUC check hook for basic_archive.archive_directory
checks that the specified directory exists.  Consequently, if the
directory does not exist at server startup, archiving will be stuck
indefinitely, even if it appears later.  To fix, remove this check
from the hook so that archiving will resume automatically once the
directory is present.  basic_archive must already be prepared to
deal with the directory disappearing at any time, so no additional
special handling is required.

Reported-by: Олег Самойлов <splarv@ya.ru>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Sergei Kornilov <sk@zsrv.org>
Discussion: https://postgr.es/m/73271769675212%40mail.yandex.ru
Backpatch-through: 15

contrib/basic_archive/basic_archive.c

index db5fd87429ef58d23243fe43ff78748f86bd1fb4..41405e3ffda55dbf881afe357c1e3ec75ca8d7ea 100644 (file)
@@ -93,13 +93,11 @@ _PG_archive_module_init(ArchiveModuleCallbacks *cb)
 /*
  * check_archive_directory
  *
- * Checks that the provided archive directory exists.
+ * Checks that the provided archive directory path isn't too long.
  */
 static bool
 check_archive_directory(char **newval, void **extra, GucSource source)
 {
-       struct stat st;
-
        /*
         * The default value is an empty string, so we have to accept that value.
         * Our check_configured callback also checks for this and prevents
@@ -118,17 +116,6 @@ check_archive_directory(char **newval, void **extra, GucSource source)
                return false;
        }
 
-       /*
-        * Do a basic sanity check that the specified archive directory exists. It
-        * could be removed at some point in the future, so we still need to be
-        * prepared for it not to exist in the actual archiving logic.
-        */
-       if (stat(*newval, &st) != 0 || !S_ISDIR(st.st_mode))
-       {
-               GUC_check_errdetail("Specified archive directory does not exist.");
-               return false;
-       }
-
        return true;
 }