Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8eba6d2

Browse files
author
Sokolov Yura
committed
cfs: if too many pages dirtied, first time try redo lockless first pass.
1 parenta25d308 commit8eba6d2

File tree

1 file changed

+15
-7
lines changed
  • src/backend/storage/file

1 file changed

+15
-7
lines changed

‎src/backend/storage/file/cfs.c‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
935935
uint32second_pass_bytes=0;
936936
inode_t**inodes= (inode_t**)palloc(RELSEG_SIZE*sizeof(inode_t*));
937937
boolremove_backups= true;
938-
boolsecond_pass_whole=false;
938+
intsecond_pass_whole=0;
939939
intn_pages,n_pages1;
940940
TimestampTzstartTime,secondTime,endTime;
941941
longsecs,secs2;
@@ -984,13 +984,16 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
984984
gotoCleanup;
985985
}
986986

987+
cfs_state->gc_stat.processedFiles+=1;
988+
cfs_gc_processed_segments+=1;
989+
987990
/* temporary lock file for fetching map snapshot */
988991
cfs_gc_lock(lock);
989992

990993
/* Reread variables after locking file */
991994
virtSize=pg_atomic_read_u32(&map->hdr.virtSize);
992995
n_pages=virtSize /BLCKSZ;
993-
996+
retry:
994997
for (i=0;i<n_pages;i++)
995998
{
996999
newMap->inodes[i]=map->inodes[i];
@@ -1000,9 +1003,6 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
10001003
/* may unlock until second phase */
10011004
cfs_gc_unlock(lock);
10021005

1003-
cfs_state->gc_stat.processedFiles+=1;
1004-
cfs_gc_processed_segments+=1;
1005-
10061006
if (!cfs_copy_inodes(inodes,n_pages,fd,fd2,&writeback,&newSize,
10071007
file_path,file_bck_path))
10081008
gotoCleanup;
@@ -1028,6 +1028,8 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
10281028
n_pages1=n_pages;
10291029
virtSize=pg_atomic_read_u32(&map->hdr.virtSize);
10301030
n_pages=virtSize /BLCKSZ;
1031+
second_pass=0;
1032+
second_pass_bytes=0;
10311033

10321034
for (i=0;i<n_pages;i++)
10331035
{
@@ -1069,10 +1071,16 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
10691071
newUsed=0;
10701072
newSize=0;
10711073
writeback=0;
1072-
second_pass_whole= true;
1074+
second_pass_whole++;
10731075
rc=lseek(fd2,0,SEEK_SET);
10741076
Assert(rc==0);
10751077
memset(newMap->inodes,0,sizeof(newMap->inodes));
1078+
elog(LOG,"CFS: retry %d whole gc file %s",second_pass_whole,
1079+
file_path);
1080+
if (second_pass_whole==1)
1081+
{
1082+
gotoretry;
1083+
}
10761084
for (i=0;i<n_pages;i++)
10771085
{
10781086
newMap->inodes[i]=map->inodes[i];
@@ -1089,7 +1097,7 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
10891097

10901098
pg_flush_data(fd2,writeback,newSize);
10911099

1092-
if (second_pass_whole)
1100+
if (second_pass_whole!=0)
10931101
{
10941102
/* truncate file to copied size */
10951103
if (ftruncate(fd2,newSize))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp