@@ -322,14 +322,22 @@ ptrack_gather_filelist(List **filelist, char *path, Oid spcOid, Oid dbOid)
322322
323323if (sret < 0 )
324324{
325- ereport (LOG ,
325+ ereport (WARNING ,
326326(errcode_for_file_access (),
327327errmsg ("ptrack: could not stat file \"%s\": %m" ,subpath )));
328328continue ;
329329}
330330
331331if (S_ISREG (fst .st_mode ))
332332{
333+ if (fst .st_size == 0 )
334+ {
335+ elog (DEBUG3 ,"ptrack: skip empty file %s" ,subpath );
336+
337+ /* But try the next one */
338+ continue ;
339+ }
340+
333341/* Regular file inside database directory, otherwise skip it */
334342if (dbOid != InvalidOid || spcOid == GLOBALTABLESPACE_OID )
335343{
@@ -406,6 +414,8 @@ ptrack_filelist_getnext(PtScanCtx * ctx)
406414RelFileNodeBackend rnodebackend ;
407415#endif
408416
417+ get_next :
418+
409419/* No more file in the list */
410420if (list_length (ctx -> filelist )== 0 )
411421return -1 ;
@@ -440,15 +450,15 @@ ptrack_filelist_getnext(PtScanCtx * ctx)
440450elog (WARNING ,"ptrack: cannot stat file %s" ,fullpath );
441451
442452/* But try the next one */
443- return ptrack_filelist_getnext ( ctx ) ;
453+ goto get_next ;
444454}
445455
446456if (fst .st_size == 0 )
447457{
448- elog (WARNING ,"ptrack: skip empty file %s" ,fullpath );
458+ elog (DEBUG3 ,"ptrack: skip empty file %s" ,fullpath );
449459
450460/* But try the next one */
451- return ptrack_filelist_getnext ( ctx ) ;
461+ goto get_next ;
452462}
453463
454464#if CFS_SUPPORT
@@ -460,7 +470,7 @@ ptrack_filelist_getnext(PtScanCtx * ctx)
460470
461471// Could not open fullpath for some reason, trying the next file.
462472if (rel_st_size == -1 )
463- return ptrack_filelist_getnext ( ctx ) ;
473+ goto get_next ;
464474}else
465475#endif
466476rel_st_size = fst .st_size ;