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

Commitcddcf78

Browse files
committed
Clarify some errors in pg_receivewal when closing WAL segments
A WAL segment closed during a WAL stream for pg_receivewal wouldgenerate incorrect error messages depending on the context, as the filename used when referring to a WAL segment ignored partial files or thecompression method used. In such cases, the error message generated(failure on close, seek or rename) would not match a physical filename. The same code paths are used by pg_basebackup, but it uses nopartial suffix so it is not impacted.7fbe0c8 has introduced in walmethods.c a callback to get the exactphysical file name used for a given context, this commit makes use of itto improve those error messages. This could be extended to more codepaths of pg_basebackup/ in the future, if necessary.Extracted from a larger patch by the same author.Author: Georgios KokolatosDiscussion:https://postgr.es/m/ZCm1J5vfyQ2E6dYvXz8si39HQ2gwxSZ3IpYaVgYa3lUwY88SLapx9EEnOf5uEwrddhx2twG7zYKjVeuP5MwZXCNPybtsGouDsAD1o2L_I5E=@pm.me
1 parent5adb067 commitcddcf78

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

‎src/bin/pg_basebackup/receivelog.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,20 +185,27 @@ open_walfile(StreamCtl *stream, XLogRecPtr startpoint)
185185
staticbool
186186
close_walfile(StreamCtl*stream,XLogRecPtrpos)
187187
{
188+
char*fn;
188189
off_tcurrpos;
189190
intr;
190191

191192
if (walfile==NULL)
192193
return true;
193194

195+
/* Note that this considers the compression used if necessary */
196+
fn=stream->walmethod->get_file_name(current_walfile_name,
197+
stream->partial_suffix);
198+
194199
currpos=stream->walmethod->get_current_pos(walfile);
200+
195201
if (currpos==-1)
196202
{
197203
pg_log_error("could not determine seek position in file \"%s\": %s",
198-
current_walfile_name,stream->walmethod->getlasterror());
204+
fn,stream->walmethod->getlasterror());
199205
stream->walmethod->close(walfile,CLOSE_UNLINK);
200206
walfile=NULL;
201207

208+
pg_free(fn);
202209
return false;
203210
}
204211

@@ -208,8 +215,7 @@ close_walfile(StreamCtl *stream, XLogRecPtr pos)
208215
r=stream->walmethod->close(walfile,CLOSE_NORMAL);
209216
else
210217
{
211-
pg_log_info("not renaming \"%s%s\", segment is not complete",
212-
current_walfile_name,stream->partial_suffix);
218+
pg_log_info("not renaming \"%s\", segment is not complete",fn);
213219
r=stream->walmethod->close(walfile,CLOSE_NO_RENAME);
214220
}
215221
}
@@ -221,10 +227,14 @@ close_walfile(StreamCtl *stream, XLogRecPtr pos)
221227
if (r!=0)
222228
{
223229
pg_log_error("could not close file \"%s\": %s",
224-
current_walfile_name,stream->walmethod->getlasterror());
230+
fn,stream->walmethod->getlasterror());
231+
232+
pg_free(fn);
225233
return false;
226234
}
227235

236+
pg_free(fn);
237+
228238
/*
229239
* Mark file as archived if requested by the caller - pg_basebackup needs
230240
* to do so as files can otherwise get archived again after promotion of a

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp