@@ -987,13 +987,13 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
987
987
cfs_state -> gc_stat .processedFiles += 1 ;
988
988
cfs_gc_processed_segments += 1 ;
989
989
990
+ retry :
990
991
/* temporary lock file for fetching map snapshot */
991
992
cfs_gc_lock (lock );
992
993
993
994
/* Reread variables after locking file */
994
995
virtSize = pg_atomic_read_u32 (& map -> hdr .virtSize );
995
996
n_pages = virtSize / BLCKSZ ;
996
- retry :
997
997
for (i = 0 ; i < n_pages ; i ++ )
998
998
{
999
999
newMap -> inodes [i ] = map -> inodes [i ];
@@ -1026,10 +1026,9 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
1026
1026
1027
1027
/* Reread variables after locking file */
1028
1028
n_pages1 = n_pages ;
1029
+ physSize = pg_atomic_read_u32 (& map -> hdr .physSize );
1029
1030
virtSize = pg_atomic_read_u32 (& map -> hdr .virtSize );
1030
1031
n_pages = virtSize / BLCKSZ ;
1031
- second_pass = 0 ;
1032
- second_pass_bytes = 0 ;
1033
1032
1034
1033
for (i = 0 ; i < n_pages ; i ++ )
1035
1034
{
@@ -1074,8 +1073,13 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
1074
1073
memset (newMap -> inodes , 0 , sizeof (newMap -> inodes ));
1075
1074
elog (LOG , "CFS: retry %d whole gc file %s" , second_pass_whole ,
1076
1075
file_path );
1077
- if (second_pass_whole == 1 )
1076
+ if (second_pass_whole == 1 && physSize < CFS_IMPLICIT_GC_THRESHOLD )
1078
1077
{
1078
+ cfs_gc_unlock (lock );
1079
+ /* sleep, cause there is possibly checkpoint is on a way */
1080
+ pg_usleep (CFS_LOCK_MAX_TIMEOUT );
1081
+ second_pass = 0 ;
1082
+ second_pass_bytes = 0 ;
1079
1083
goto retry ;
1080
1084
}
1081
1085
for (i = 0 ; i < n_pages ; i ++ )
0 commit comments