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

Commit 63c2810

Browse files
committed
fix restoring highly compressed WAL
gzip surprisingly emits a lot of zeroes when compression ratio is high. It triggered branch where FIO_PAGE_ZERO is emitted in agent but not handled in fio_sned_file_gz properly. Fix it.
1 parent e39a31e commit 63c2810

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/utils/file.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2537,11 +2537,22 @@ fio_send_file_gz(const char *from_fullpath, FILE* out, char **errormsg)
25372537
exit_code = hdr.arg;
25382538
goto cleanup;
25392539
}
2540-
else if (hdr.cop == FIO_PAGE)
2540+
else if (hdr.cop == FIO_PAGE || hdr.cop == FIO_PAGE_ZERO)
25412541
{
25422542
int rc;
2543-
Assert(hdr.size <= CHUNK_SIZE);
2544-
IO_CHECK(fio_read_all(fio_stdin, in_buf, hdr.size), hdr.size);
2543+
unsigned size;
2544+
if (hdr.cop == FIO_PAGE)
2545+
{
2546+
Assert(hdr.size <= CHUNK_SIZE);
2547+
size = hdr.size;
2548+
IO_CHECK(fio_read_all(fio_stdin, in_buf, hdr.size), hdr.size);
2549+
}
2550+
else
2551+
{
2552+
Assert(hdr.arg <= CHUNK_SIZE);
2553+
size = hdr.arg;
2554+
memset(in_buf, 0, hdr.arg);
2555+
}
25452556

25462557
/* We have received a chunk of compressed data, lets decompress it */
25472558
if (strm == NULL)
@@ -2552,7 +2563,7 @@ fio_send_file_gz(const char *from_fullpath, FILE* out, char **errormsg)
25522563

25532564
/* The fields next_in, avail_in initialized before init */
25542565
strm->next_in = (Bytef *)in_buf;
2555-
strm->avail_in = hdr.size;
2566+
strm->avail_in = size;
25562567

25572568
rc = inflateInit2(strm, 15 + 16);
25582569

@@ -2569,7 +2580,7 @@ fio_send_file_gz(const char *from_fullpath, FILE* out, char **errormsg)
25692580
else
25702581
{
25712582
strm->next_in = (Bytef *)in_buf;
2572-
strm->avail_in = hdr.size;
2583+
strm->avail_in = size;
25732584
}
25742585

25752586
strm->next_out = (Bytef *)out_buf; /* output buffer */

0 commit comments

Comments
 (0)