From 528c9db58c6d6f24313aa971e2ea93f9ed6286e4 Mon Sep 17 00:00:00 2001 From: Yura Sokolov Date: Tue, 21 Mar 2023 13:48:52 +0300 Subject: [PATCH] [PBCKP-564] Don't spam with "skip empty file" message And don't add empty files to file list at all. Fixes #35 --- ptrack.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/ptrack.c b/ptrack.c index c9ee56a..22a2acf 100644 --- a/ptrack.c +++ b/ptrack.c @@ -322,7 +322,7 @@ ptrack_gather_filelist(List **filelist, char *path, Oid spcOid, Oid dbOid) if (sret < 0) { - ereport(LOG, + ereport(WARNING, (errcode_for_file_access(), errmsg("ptrack: could not stat file \"%s\": %m", subpath))); continue; @@ -330,6 +330,14 @@ ptrack_gather_filelist(List **filelist, char *path, Oid spcOid, Oid dbOid) if (S_ISREG(fst.st_mode)) { + if (fst.st_size == 0) + { + elog(DEBUG3, "ptrack: skip empty file %s", subpath); + + /* But try the next one */ + continue; + } + /* Regular file inside database directory, otherwise skip it */ if (dbOid != InvalidOid || spcOid == GLOBALTABLESPACE_OID) { @@ -406,6 +414,8 @@ ptrack_filelist_getnext(PtScanCtx * ctx) RelFileNodeBackend rnodebackend; #endif +get_next: + /* No more file in the list */ if (list_length(ctx->filelist) == 0) return -1; @@ -440,15 +450,15 @@ ptrack_filelist_getnext(PtScanCtx * ctx) elog(WARNING, "ptrack: cannot stat file %s", fullpath); /* But try the next one */ - return ptrack_filelist_getnext(ctx); + goto get_next; } if (fst.st_size == 0) { - elog(WARNING, "ptrack: skip empty file %s", fullpath); + elog(DEBUG3, "ptrack: skip empty file %s", fullpath); /* But try the next one */ - return ptrack_filelist_getnext(ctx); + goto get_next; } #if CFS_SUPPORT @@ -460,7 +470,7 @@ ptrack_filelist_getnext(PtScanCtx * ctx) // Could not open fullpath for some reason, trying the next file. if(rel_st_size == -1) - return ptrack_filelist_getnext(ctx); + goto get_next; } else #endif rel_st_size = fst.st_size;