Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 33352b9

Browse files
committed
In basebackup.c, perform end-of-file test after checksum validation.
We read blocks of data from files that we're backing up in chunks, some multiple of BLCKSZ for each read. If checksum verification fails, we then try rereading just the one block for which validation failed. If that block happened to be the first block of the chunk, and if the file was concurrently truncated to remove that block, then we'd reach a call to bbsink_archive_contents() with a buffer length of 0. That causes an assertion failure. As far as I can see, there are no particularly bad consequences if this happens in a non-assert build, and it's pretty unlikely to happen in the first place because it requires a series of somewhat unlikely things to happen in very quick succession. However, assertion failures are bad, so rearrange the code to avoid that possibility. Patch by me, reviewed by Michael Paquier. Discussion: http://postgr.es/m/CA+TgmoZ_fFAoU6mrHt9QBs+dcYhN6yXenGTTMRebZNhtwPwHyg@mail.gmail.com
1 parent d3406d8 commit 33352b9

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/backend/backup/basebackup.c

+9-8
Original file line numberDiff line numberDiff line change
@@ -1567,14 +1567,6 @@ sendFile(bbsink *sink, const char *readfilename, const char *tarfilename,
15671567
Min(sink->bbs_buffer_length, remaining),
15681568
len, readfilename, true);
15691569

1570-
/*
1571-
* If we hit end-of-file, a concurrent truncation must have occurred.
1572-
* That's not an error condition, because WAL replay will fix things
1573-
* up.
1574-
*/
1575-
if (cnt == 0)
1576-
break;
1577-
15781570
/*
15791571
* The checksums are verified at block level, so we iterate over the
15801572
* buffer in chunks of BLCKSZ, after making sure that
@@ -1677,6 +1669,15 @@ sendFile(bbsink *sink, const char *readfilename, const char *tarfilename,
16771669
}
16781670
}
16791671

1672+
/*
1673+
* If we hit end-of-file, a concurrent truncation must have occurred.
1674+
* That's not an error condition, because WAL replay will fix things
1675+
* up.
1676+
*/
1677+
if (cnt == 0)
1678+
break;
1679+
1680+
/* Archive the data we just read. */
16801681
bbsink_archive_contents(sink, cnt);
16811682

16821683
/* Also feed it to the checksum machinery. */

0 commit comments

Comments
 (0)