On 2/21/20 1:36 AM, Michael Paquier wrote: > On Thu, Feb 20, 2020 at 05:38:15PM +0100, Bernd Helmle wrote: >> So i propose a different approach like the attached patch tries to >> implement: instead of just blindly iterating over directory contents >> and filter them out, reference the tablespace location and >> TABLESPACE_VERSION_DIRECTORY directly. This is done by a new function >> scan_tablespaces() which is specialized in just follow the >> symlinks/junctions in pg_tblspc and call scan_directory() with just >> what it has found there. It will also honour directories, just in case >> an experienced DBA has copied over the tablespace into pg_tblspc >> directly. > > + if (S_ISREG(st.st_mode)) > + { > + pg_log_debug("ignoring file %s in pg_tblspc", de->d_name); > + continue; > + } > We don't do that for the normal directory scan path, so it does not > strike me as a good idea on consistency ground. As a whole, I don't > see much point in having a separate routine which is just roughly a > duplicate of scan_directory(), and I think that we had better just add > the check looking for matches with TABLESPACE_VERSION_DIRECTORY > directly when having a directory, if subdir is "pg_tblspc". That > also makes the patch much shorter.
+1. This is roughly what pg_basebackup does and it seems simpler to me. Regards, -- -David da...@pgmasters.net