Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 069d5ba

Browse files
author
Sokolov Yura
committed
cfs: order write gc completion
1 parent 2383ab6 commit 069d5ba

File tree

1 file changed

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

1 file changed

+8
-1
lines changed

src/backend/storage/file/cfs.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,6 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
12001200
memcpy(map->inodes, newMap->inodes, n_pages * sizeof(inode_t));
12011201
pg_atomic_write_u32(&map->hdr.usedSize, newUsed);
12021202
pg_atomic_write_u32(&map->hdr.physSize, newSize);
1203-
pg_atomic_write_u32(&map->gc_active, false);
12041203
map->generation += 1; /* force all backends to reopen the file */
12051204

12061205
/* Before removing backup files and releasing locks
@@ -1210,6 +1209,14 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
12101209
elog(WARNING, "CFS failed to sync map %s: %m", map_path);
12111210
goto Cleanup;
12121211
}
1212+
/* now we can safely set gc completion */
1213+
pg_atomic_write_u32(&map->gc_active, false);
1214+
/* and need to sync it again */
1215+
if (cfs_msync(map) < 0)
1216+
{
1217+
elog(WARNING, "CFS failed to sync map %s: %m", map_path);
1218+
goto Cleanup;
1219+
}
12131220
if (pg_fsync(md) < 0)
12141221
{
12151222
elog(WARNING, "CFS failed to sync file %s: %m", map_path);

0 commit comments

Comments
 (0)