Skip to content

Commit 54ce23d

Browse files
committed
Add memory barrier
1 parent 4a8146b commit 54ce23d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/backend/storage/file/cfs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,7 @@ static bool cfs_gc_file(char* map_path, bool background)
986986
else
987987
remove_backups = true; /* we don't need backups anymore */
988988

989+
pg_write_barrier();
989990
pg_atomic_fetch_sub_u32(&map->lock, CFS_GC_LOCK); /* release lock */
990991

991992
/* remove map backup file */

src/backend/storage/file/fd.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,12 +1708,16 @@ static bool
17081708
FileLock(File file)
17091709
{
17101710
Vfd *vfdP = &VfdCache[file];
1711+
uint64 map_generation;
17111712

17121713
/* protect file from GC */
17131714
cfs_lock_file(vfdP->map, vfdP->fileName);
17141715

1716+
map_generation = vfdP->map->generation;
1717+
pg_read_barrier();
1718+
17151719
/* Reopen file, because it was rewritten by gc */
1716-
if (vfdP->generation != vfdP->map->generation)
1720+
if (vfdP->generation != map_generation)
17171721
{
17181722
close(vfdP->fd);
17191723
vfdP->fd = BasicOpenFile(vfdP->fileName, vfdP->fileFlags, vfdP->fileMode);
@@ -1722,7 +1726,7 @@ FileLock(File file)
17221726
DO_DB(elog(LOG, "RE_OPEN FAILED: %d", errno));
17231727
return false;
17241728
}
1725-
vfdP->generation = vfdP->map->generation;
1729+
vfdP->generation = map_generation;
17261730
}
17271731
return true;
17281732
}
@@ -2005,6 +2009,8 @@ FileWrite(File file, char *buffer, int amount)
20052009
errno = 0;
20062010
returnCode = write(vfdP->fd, buffer, amount);
20072011

2012+
Assert(vfdP->generation = vfdP->map->generation);
2013+
20082014
/* if write didn't set errno, assume problem is no disk space */
20092015
if (returnCode != amount && errno == 0)
20102016
errno = ENOSPC;

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