1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-13 01:00:23 +02:00

Fix zero-length reads causing problems for IO filters that did not expect them.

The IoRead object was passing zero-length buffers into the filter processing code but not all the filters were happy about getting them.

In particular, the gzip compression filter failed if it was given no input directly after it had flushed all of its buffers.  This made the problem rather intermittent even though a zero-length buffer was being passed to the filter at the end of every file.  It also explains why tweaking compress-level or buffer-size allowed the file to go through.

Since this error was happening after all processing had completed, there does not appear to be any risk that successfully processed files were corrupted.

Reported by brunre01, jwpit, Tomasz Kontusz, guruguruguru.
This commit is contained in:
David Steele
2019-04-18 21:21:35 -04:00
parent 670fa88a98
commit 2d73de1d36
3 changed files with 46 additions and 2 deletions

View File

@ -255,11 +255,23 @@ testRun(void)
TEST_RESULT_VOID(ioReadFree(read), " free read object");
TEST_RESULT_VOID(ioReadFree(NULL), " free null read object");
// Read a zero-length buffer to be sure it is not passed on to the filter group
// -------------------------------------------------------------------------------------------------------------------------
IoBufferRead *bufferRead = NULL;
ioBufferSizeSet(2);
buffer = bufNew(2);
Buffer *bufferOriginal = bufNewZ("123");
Buffer *bufferOriginal = bufNew(0);
TEST_ASSIGN(bufferRead, ioBufferReadNew(bufferOriginal), "create empty buffer read object");
TEST_RESULT_BOOL(ioReadOpen(ioBufferReadIo(bufferRead)), true, " open");
TEST_RESULT_BOOL(ioReadEof(ioBufferReadIo(bufferRead)), false, " not eof");
TEST_RESULT_SIZE(ioRead(ioBufferReadIo(bufferRead), buffer), 0, " read 0 bytes");
TEST_RESULT_BOOL(ioReadEof(ioBufferReadIo(bufferRead)), true, " now eof");
// -------------------------------------------------------------------------------------------------------------------------
ioBufferSizeSet(2);
buffer = bufNew(2);
bufferOriginal = bufNewZ("123");
MEM_CONTEXT_TEMP_BEGIN()
{