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

Appearance settings

Commit 14fe804

Browse filesBrowse 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 all the files in the source data directory using a WITH RECURSIVE query, returning a NULL result for a file's metadata if it gets removed between the moment it is listed in a directory and the moment its metadata is obtained with pg_stat_file() (say a recycled WAL segment). The query result was processed in such a way that for each tuple we checked only that the first file's metadata was NULL. This could have two consequences, both resulting in a failure of the rewind: - If the first tuple referred to a removed file, all files from the source 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 we know that a file is going to be skipped. Issue introduced by b36805f, so backpatch down to 9.5. Author: Justin Pryzby, Michael Paquier Reviewed-by: Daniel Gustafsson, Masahiko Sawada Discussion: https://postgr.es/m/20200713061010.GC23581@telsasoft.com Backpatch-through: 9.5
1 parent c732df1 commit 14fe804
Copy full SHA for 14fe804

File tree

Expand file treeCollapse file tree

1 file changed

+10
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-5
lines changed

‎src/bin/pg_rewind/libpq_fetch.c

Copy file name to clipboardExpand all lines: src/bin/pg_rewind/libpq_fetch.c
+10-5Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,13 @@ libpqProcessFileList(void)
221221
/* Read result to local variables */
222222
for (i = 0; i < PQntuples(res); i++)
223223
{
224-
char *path = PQgetvalue(res, i, 0);
225-
int64 filesize = atol(PQgetvalue(res, i, 1));
226-
bool isdir = (strcmp(PQgetvalue(res, i, 2), "t") == 0);
227-
char *link_target = PQgetvalue(res, i, 3);
224+
char *path;
225+
int64 filesize;
226+
bool isdir;
227+
char *link_target;
228228
file_type_t type;
229229

230-
if (PQgetisnull(res, 0, 1))
230+
if (PQgetisnull(res, i, 1))
231231
{
232232
/*
233233
* The file was removed from the server while the query was
@@ -236,6 +236,11 @@ libpqProcessFileList(void)
236236
continue;
237237
}
238238

239+
path = PQgetvalue(res, i, 0);
240+
filesize = atol(PQgetvalue(res, i, 1));
241+
isdir = (strcmp(PQgetvalue(res, i, 2), "t") == 0);
242+
link_target = PQgetvalue(res, i, 3);
243+
239244
if (link_target[0])
240245
type = FILE_TYPE_SYMLINK;
241246
else if (isdir)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.