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

Commit28cc297

Browse files
committed
Use pg_pwrite_zeros() in walmethods.c
This change impacts pg_receivewal and pg_basebackup, for the pre-paddingwith zeros of all the new non-compressed WAL segments, so as the code ismore robust on partial writes. This makes the code consistent with thebackend (XLogFileInitInternal) when wal_init_zeros is enabled for theWAL segment initialization.Author: Bharath RupireddyReviewed-by: Nathan Bossart, Andres Freund, Thomas Munro, MichaelPaquierDiscussion:https://postgr.es/m/CALj2ACUq7nAb7=bJNbK3yYmp-SZhJcXFR_pLk8un6XgDzDF3OA@mail.gmail.com
1 parent3bdbdf5 commit28cc297

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

‎src/bin/pg_basebackup/walmethods.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -220,22 +220,21 @@ dir_open_for_write(WalWriteMethod *wwmethod, const char *pathname,
220220
/* Do pre-padding on non-compressed files */
221221
if (pad_to_size&&wwmethod->compression_algorithm==PG_COMPRESSION_NONE)
222222
{
223-
PGAlignedXLogBlockzerobuf;
224-
intbytes;
223+
ssize_trc;
225224

226-
memset(zerobuf.data,0,XLOG_BLCKSZ);
227-
for (bytes=0;bytes<pad_to_size;bytes+=XLOG_BLCKSZ)
225+
rc=pg_pwrite_zeros(fd,pad_to_size);
226+
227+
if (rc<0)
228228
{
229-
errno=0;
230-
if (write(fd,zerobuf.data,XLOG_BLCKSZ)!=XLOG_BLCKSZ)
231-
{
232-
/* If write didn't set errno, assume problem is no disk space */
233-
wwmethod->lasterrno=errno ?errno :ENOSPC;
234-
close(fd);
235-
returnNULL;
236-
}
229+
wwmethod->lasterrno=errno;
230+
close(fd);
231+
returnNULL;
237232
}
238233

234+
/*
235+
* pg_pwrite() (called via pg_pwrite_zeros()) may have moved the file
236+
* position, so reset it (see win32pwrite.c).
237+
*/
239238
if (lseek(fd,0,SEEK_SET)!=0)
240239
{
241240
wwmethod->lasterrno=errno;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp