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

Commit1e2fddf

Browse files
committed
Handle fsync failures in pg_receivewal and pg_recvlogical
It is not safe to simply report an fsync error and continue. We mustexit the program instead.Reviewed-by: Michael Paquier <michael@paquier.xyz>Reviewed-by: Sehrope Sarkuni <sehrope@jackdb.com>Discussion:https://www.postgresql.org/message-id/flat/9b49fe44-8f3e-eca9-5914-29e9e99030bf@2ndquadrant.com
1 parenteb43f3d commit1e2fddf

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

‎src/bin/pg_basebackup/pg_recvlogical.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ OutputFsync(TimestampTz now)
192192

193193
if (fsync(outfd)!=0)
194194
{
195-
pg_log_error("could not fsync file \"%s\": %m",outfile);
196-
return false;
195+
pg_log_fatal("could not fsync file \"%s\": %m",outfile);
196+
exit(1);
197197
}
198198

199199
return true;

‎src/bin/pg_basebackup/receivelog.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ open_walfile(StreamCtl *stream, XLogRecPtr startpoint)
134134
/* fsync file in case of a previous crash */
135135
if (stream->walmethod->sync(f)!=0)
136136
{
137-
pg_log_error("could not fsync existing write-ahead log file \"%s\": %s",
137+
pg_log_fatal("could not fsync existing write-ahead log file \"%s\": %s",
138138
fn,stream->walmethod->getlasterror());
139139
stream->walmethod->close(f,CLOSE_UNLINK);
140-
return false;
140+
exit(1);
141141
}
142142

143143
walfile=f;
@@ -763,9 +763,9 @@ HandleCopyStream(PGconn *conn, StreamCtl *stream,
763763
{
764764
if (stream->walmethod->sync(walfile)!=0)
765765
{
766-
pg_log_error("could not fsync file \"%s\": %s",
766+
pg_log_fatal("could not fsync file \"%s\": %s",
767767
current_walfile_name,stream->walmethod->getlasterror());
768-
gotoerror;
768+
exit(1);
769769
}
770770
lastFlushPosition=blockpos;
771771

@@ -1015,9 +1015,9 @@ ProcessKeepaliveMsg(PGconn *conn, StreamCtl *stream, char *copybuf, int len,
10151015
*/
10161016
if (stream->walmethod->sync(walfile)!=0)
10171017
{
1018-
pg_log_error("could not fsync file \"%s\": %s",
1018+
pg_log_fatal("could not fsync file \"%s\": %s",
10191019
current_walfile_name,stream->walmethod->getlasterror());
1020-
return false;
1020+
exit(1);
10211021
}
10221022
lastFlushPosition=blockpos;
10231023
}

‎src/bin/pg_basebackup/walmethods.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ tar_close(Walfile f, WalCloseMethod method)
864864

865865
/* Always fsync on close, so the padding gets fsynced */
866866
if (tar_sync(f)<0)
867-
return-1;
867+
exit(1);
868868

869869
/* Clean up and done */
870870
pg_free(tf->pathname);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp