Skip to content

Commit 05449c2

Browse files
author
Sokolov Yura
committed
cfs: force whole compaction under lock on huge files
1 parent 9b03e0c commit 05449c2

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/backend/storage/file/cfs.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,8 +992,11 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
992992
cfs_gc_lock(lock);
993993

994994
/* Reread variables after locking file */
995+
physSize = pg_atomic_read_u32(&map->hdr.physSize);
995996
virtSize = pg_atomic_read_u32(&map->hdr.virtSize);
996997
n_pages = virtSize / BLCKSZ;
998+
if (physSize >= CFS_RED_LINE)
999+
goto forceWhole;
9971000
for (i = 0; i < n_pages; i++)
9981001
{
9991002
newMap->inodes[i] = map->inodes[i];
@@ -1073,7 +1076,7 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
10731076
memset(newMap->inodes, 0, sizeof(newMap->inodes));
10741077
elog(LOG, "CFS: retry %d whole gc file %s", second_pass_whole,
10751078
file_path);
1076-
if (second_pass_whole == 1 && physSize < CFS_IMPLICIT_GC_THRESHOLD)
1079+
if (second_pass_whole == 1 && physSize < CFS_RETRY_GC_THRESHOLD)
10771080
{
10781081
cfs_gc_unlock(lock);
10791082
/* sleep, cause there is possibly checkpoint is on a way */
@@ -1082,6 +1085,7 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
10821085
second_pass_bytes = 0;
10831086
goto retry;
10841087
}
1088+
forceWhole:
10851089
for (i = 0; i < n_pages; i++)
10861090
{
10871091
newMap->inodes[i] = map->inodes[i];

src/include/storage/cfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ typedef uint64 inode_t;
5353
#define CFS_INODE_CLEAN_FLAG ((inode_t)1 << 63)
5454

5555
#define CFS_IMPLICIT_GC_THRESHOLD 0x80000000U /* 2Gb */
56+
#define CFS_RETRY_GC_THRESHOLD 0x60000000U /* 1.5Gb */
5657
#define CFS_RED_LINE 0xC0000000U /* 3Gb */
5758

5859
size_t cfs_compress(void* dst, size_t dst_size, void const* src, size_t src_size);

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