Skip to content

Commit 9b03e0c

Browse files
author
Sokolov Yura
committed
cfs: sleep a bit before first retry, so write heavy load may finish.
1 parent 870a86c commit 9b03e0c

File tree

1 file changed

+8
-4
lines changed
  • src/backend/storage/file

1 file changed

+8
-4
lines changed

src/backend/storage/file/cfs.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -987,13 +987,13 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
987987
cfs_state->gc_stat.processedFiles += 1;
988988
cfs_gc_processed_segments += 1;
989989

990+
retry:
990991
/* temporary lock file for fetching map snapshot */
991992
cfs_gc_lock(lock);
992993

993994
/* Reread variables after locking file */
994995
virtSize = pg_atomic_read_u32(&map->hdr.virtSize);
995996
n_pages = virtSize / BLCKSZ;
996-
retry:
997997
for (i = 0; i < n_pages; i++)
998998
{
999999
newMap->inodes[i] = map->inodes[i];
@@ -1026,10 +1026,9 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
10261026

10271027
/* Reread variables after locking file */
10281028
n_pages1 = n_pages;
1029+
physSize = pg_atomic_read_u32(&map->hdr.physSize);
10291030
virtSize = pg_atomic_read_u32(&map->hdr.virtSize);
10301031
n_pages = virtSize / BLCKSZ;
1031-
second_pass = 0;
1032-
second_pass_bytes = 0;
10331032

10341033
for (i = 0; i < n_pages; i++)
10351034
{
@@ -1074,8 +1073,13 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
10741073
memset(newMap->inodes, 0, sizeof(newMap->inodes));
10751074
elog(LOG, "CFS: retry %d whole gc file %s", second_pass_whole,
10761075
file_path);
1077-
if (second_pass_whole == 1)
1076+
if (second_pass_whole == 1 && physSize < CFS_IMPLICIT_GC_THRESHOLD)
10781077
{
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;
10791083
goto retry;
10801084
}
10811085
for (i = 0; i < n_pages; i++)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy