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

Commit1420617

Browse files
committed
Change client-side fsync_fname() to report errors fatally
Given all we have learned about fsync() error handling in the last fewyears, reporting an fsync() error non-fatally is not useful,unless you don't care much about the file, in which case you probablydon't need to use fsync() in the first place.Change fsync_fname() and durable_rename() to exit(1) on fsync() errorsother than those that we specifically chose to ignore.This affects initdb, pg_basebackup, pg_checksums, pg_dump, pg_dumpall,and pg_rewind.Reviewed-by: Michael Paquier <michael@paquier.xyz>Discussion:https://www.postgresql.org/message-id/flat/d239d1bd-aef0-ca7c-dc0a-da14bdcf0392%402ndquadrant.com
1 parenta91e2fa commit1420617

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

‎src/common/file_utils.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ static void walkdir(const char *path,
5151
* fsyncing, and might not have privileges to write at all.
5252
*
5353
* serverVersion indicates the version of the server to be fsync'd.
54-
*
55-
* Errors are reported but not considered fatal.
5654
*/
5755
void
5856
fsync_pgdata(constchar*pg_data,
@@ -250,8 +248,8 @@ pre_sync_fname(const char *fname, bool isdir)
250248
* fsync_fname -- Try to fsync a file or directory
251249
*
252250
* Ignores errors trying to open unreadable files, or trying to fsync
253-
* directories on systems where that isn't allowed/required.Reports
254-
*other errors non-fatally.
251+
* directories on systems where that isn't allowed/required.All other errors
252+
*are fatal.
255253
*/
256254
int
257255
fsync_fname(constchar*fname,boolisdir)
@@ -294,9 +292,9 @@ fsync_fname(const char *fname, bool isdir)
294292
*/
295293
if (returncode!=0&& !(isdir&& (errno==EBADF||errno==EINVAL)))
296294
{
297-
pg_log_error("could not fsync file \"%s\": %m",fname);
295+
pg_log_fatal("could not fsync file \"%s\": %m",fname);
298296
(void)close(fd);
299-
return-1;
297+
exit(EXIT_FAILURE);
300298
}
301299

302300
(void)close(fd);
@@ -364,9 +362,9 @@ durable_rename(const char *oldfile, const char *newfile)
364362
{
365363
if (fsync(fd)!=0)
366364
{
367-
pg_log_error("could not fsync file \"%s\": %m",newfile);
365+
pg_log_fatal("could not fsync file \"%s\": %m",newfile);
368366
close(fd);
369-
return-1;
367+
exit(EXIT_FAILURE);
370368
}
371369
close(fd);
372370
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp