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

Commitc6d33d1

Browse files
committed
Fix handling of missing files when using pg_rewind with online source
When working with an online source cluster, pg_rewind gets a list of allthe files in the source data directory using a WITH RECURSIVE query,returning a NULL result for a file's metadata if it gets removed betweenthe moment it is listed in a directory and the moment its metadata isobtained with pg_stat_file() (say a recycled WAL segment). The queryresult was processed in such a way that for each tuple we checked onlythat the first file's metadata was NULL. This could have twoconsequences, both resulting in a failure of the rewind:- If the first tuple referred to a removed file, all files from thesource would be ignored.- Any file actually missing would not be considered as such.While on it, rework slightly the code so as no values are saved if weknow that a file is going to be skipped.Issue introduced byb36805f, so backpatch down to 9.5.Author: Justin Pryzby, Michael PaquierReviewed-by: Daniel Gustafsson, Masahiko SawadaDiscussion:https://postgr.es/m/20200713061010.GC23581@telsasoft.comBackpatch-through: 9.5
1 parente9f0311 commitc6d33d1

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

‎src/bin/pg_rewind/libpq_fetch.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,13 @@ libpqProcessFileList(void)
216216
/* Read result to local variables */
217217
for (i=0;i<PQntuples(res);i++)
218218
{
219-
char*path=PQgetvalue(res,i,0);
220-
int64filesize=atol(PQgetvalue(res,i,1));
221-
boolisdir= (strcmp(PQgetvalue(res,i,2),"t")==0);
222-
char*link_target=PQgetvalue(res,i,3);
219+
char*path;
220+
int64filesize;
221+
boolisdir;
222+
char*link_target;
223223
file_type_ttype;
224224

225-
if (PQgetisnull(res,0,1))
225+
if (PQgetisnull(res,i,1))
226226
{
227227
/*
228228
* The file was removed from the server while the query was
@@ -231,6 +231,11 @@ libpqProcessFileList(void)
231231
continue;
232232
}
233233

234+
path=PQgetvalue(res,i,0);
235+
filesize=atol(PQgetvalue(res,i,1));
236+
isdir= (strcmp(PQgetvalue(res,i,2),"t")==0);
237+
link_target=PQgetvalue(res,i,3);
238+
234239
if (link_target[0])
235240
type=FILE_TYPE_SYMLINK;
236241
elseif (isdir)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp