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

Commitfd6b510

Browse files
committed
fsync directory after rename
1 parente2b6257 commitfd6b510

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ static bool cfs_gc_file(char* map_path, bool background)
706706
cfs_state->gc_stat.scannedFiles+=1;
707707

708708
/* do we need to perform defragmentation? */
709-
if ((physSize-usedSize)*100>physSize*cfs_gc_threshold)
709+
if ((uint64)(physSize-usedSize)*100>(uint64)physSize*cfs_gc_threshold)
710710
{
711711
longdelay=CFS_LOCK_MIN_TIMEOUT;
712712
char*file_path= (char*)palloc(suf+1);
@@ -950,6 +950,11 @@ static bool cfs_gc_file(char* map_path, bool background)
950950
elog(WARNING,"CFS failed to rename file %s: %m",file_path);
951951
gotoCleanup;
952952
}
953+
if (fsync_parent_path(file_path,LOG)!=0)
954+
{
955+
elog(WARNING,"CFS failed to sync directory for file %s: %m",file_path);
956+
gotoCleanup;
957+
}
953958

954959
ReplaceMap:
955960
/*

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ static void pre_sync_fname(const char *fname, bool isdir, int elevel);
330330
staticvoiddatadir_fsync_fname(constchar*fname,boolisdir,intelevel);
331331

332332
staticintfsync_fname_ext(constchar*fname,boolisdir,boolignore_perm,intelevel);
333-
staticintfsync_parent_path(constchar*fname,intelevel);
334333

335334

336335
/*
@@ -3520,7 +3519,7 @@ fsync_fname_ext(const char *fname, bool isdir, bool ignore_perm, int elevel)
35203519
* This is aimed at making file operations persistent on disk in case of
35213520
* an OS crash or power failure.
35223521
*/
3523-
staticint
3522+
int
35243523
fsync_parent_path(constchar*fname,intelevel)
35253524
{
35263525
charparentpath[MAXPGPATH];

‎src/include/storage/cfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include"port/atomics.h"
77
#include"storage/rijndael.h"
88

9-
#defineCFS_VERSION "0.36"
9+
#defineCFS_VERSION "0.41"
1010

1111
#defineCFS_GC_LOCK 0x10000000
1212

‎src/include/storage/fd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ extern intpg_fsync_writethrough(int fd);
120120
externintpg_fdatasync(intfd);
121121
externvoidpg_flush_data(intfd,off_toffset,off_tamount);
122122
externvoidfsync_fname(constchar*fname,boolisdir);
123+
externintfsync_parent_path(constchar*fname,intelevel);
123124
externintdurable_rename(constchar*oldfile,constchar*newfile,intloglevel);
124125
externintdurable_link_or_rename(constchar*oldfile,constchar*newfile,intloglevel);
125126
externvoidSyncDataDirectory(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp