mirror of
https://github.com/postgres/postgres.git
synced 2026-04-15 22:10:45 -04:00
Exit after fatal errors in client-side compression code.
It looks like whoever wrote the astreamer (nee bbstreamer) code thought that pg_log_error() is equivalent to elog(ERROR), but it's not; it just prints a message. So all these places tried to continue on after a compression or decompression error return, with the inevitable result being garbage output and possibly cascading error messages. We should use pg_fatal() instead. These error conditions are probably pretty unlikely in practice, which no doubt accounts for the lack of field complaints. Author: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Chao Li <li.evan.chao@gmail.com> Discussion: https://postgr.es/m/1531718.1772644615@sss.pgh.pa.us Backpatch-through: 15
This commit is contained in:
parent
8bfaae6fb2
commit
9a42888a32
3 changed files with 17 additions and 17 deletions
|
|
@ -293,7 +293,7 @@ bbstreamer_gzip_decompressor_content(bbstreamer *streamer,
|
|||
res = inflate(zs, Z_NO_FLUSH);
|
||||
|
||||
if (res == Z_STREAM_ERROR)
|
||||
pg_log_error("could not decompress data: %s", zs->msg);
|
||||
pg_fatal("could not decompress data: %s", zs->msg);
|
||||
|
||||
mystreamer->bytes_written =
|
||||
mystreamer->base.bbs_buffer.maxlen - zs->avail_out;
|
||||
|
|
|
|||
|
|
@ -92,8 +92,8 @@ bbstreamer_lz4_compressor_new(bbstreamer *next, pg_compress_specification *compr
|
|||
|
||||
ctxError = LZ4F_createCompressionContext(&streamer->cctx, LZ4F_VERSION);
|
||||
if (LZ4F_isError(ctxError))
|
||||
pg_log_error("could not create lz4 compression context: %s",
|
||||
LZ4F_getErrorName(ctxError));
|
||||
pg_fatal("could not create lz4 compression context: %s",
|
||||
LZ4F_getErrorName(ctxError));
|
||||
|
||||
return &streamer->base;
|
||||
#else
|
||||
|
|
@ -137,8 +137,8 @@ bbstreamer_lz4_compressor_content(bbstreamer *streamer,
|
|||
&mystreamer->prefs);
|
||||
|
||||
if (LZ4F_isError(compressed_size))
|
||||
pg_log_error("could not write lz4 header: %s",
|
||||
LZ4F_getErrorName(compressed_size));
|
||||
pg_fatal("could not write lz4 header: %s",
|
||||
LZ4F_getErrorName(compressed_size));
|
||||
|
||||
mystreamer->bytes_written += compressed_size;
|
||||
mystreamer->header_written = true;
|
||||
|
|
@ -186,8 +186,8 @@ bbstreamer_lz4_compressor_content(bbstreamer *streamer,
|
|||
next_in, len, NULL);
|
||||
|
||||
if (LZ4F_isError(compressed_size))
|
||||
pg_log_error("could not compress data: %s",
|
||||
LZ4F_getErrorName(compressed_size));
|
||||
pg_fatal("could not compress data: %s",
|
||||
LZ4F_getErrorName(compressed_size));
|
||||
|
||||
mystreamer->bytes_written += compressed_size;
|
||||
}
|
||||
|
|
@ -238,8 +238,8 @@ bbstreamer_lz4_compressor_finalize(bbstreamer *streamer)
|
|||
next_out, avail_out, NULL);
|
||||
|
||||
if (LZ4F_isError(compressed_size))
|
||||
pg_log_error("could not end lz4 compression: %s",
|
||||
LZ4F_getErrorName(compressed_size));
|
||||
pg_fatal("could not end lz4 compression: %s",
|
||||
LZ4F_getErrorName(compressed_size));
|
||||
|
||||
mystreamer->bytes_written += compressed_size;
|
||||
|
||||
|
|
@ -351,8 +351,8 @@ bbstreamer_lz4_decompressor_content(bbstreamer *streamer,
|
|||
next_in, &read_size, NULL);
|
||||
|
||||
if (LZ4F_isError(ret))
|
||||
pg_log_error("could not decompress data: %s",
|
||||
LZ4F_getErrorName(ret));
|
||||
pg_fatal("could not decompress data: %s",
|
||||
LZ4F_getErrorName(ret));
|
||||
|
||||
/* Update input buffer based on number of bytes consumed */
|
||||
avail_in -= read_size;
|
||||
|
|
|
|||
|
|
@ -165,8 +165,8 @@ bbstreamer_zstd_compressor_content(bbstreamer *streamer,
|
|||
&inBuf, ZSTD_e_continue);
|
||||
|
||||
if (ZSTD_isError(yet_to_flush))
|
||||
pg_log_error("could not compress data: %s",
|
||||
ZSTD_getErrorName(yet_to_flush));
|
||||
pg_fatal("could not compress data: %s",
|
||||
ZSTD_getErrorName(yet_to_flush));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -207,8 +207,8 @@ bbstreamer_zstd_compressor_finalize(bbstreamer *streamer)
|
|||
&in, ZSTD_e_end);
|
||||
|
||||
if (ZSTD_isError(yet_to_flush))
|
||||
pg_log_error("could not compress data: %s",
|
||||
ZSTD_getErrorName(yet_to_flush));
|
||||
pg_fatal("could not compress data: %s",
|
||||
ZSTD_getErrorName(yet_to_flush));
|
||||
|
||||
} while (yet_to_flush > 0);
|
||||
|
||||
|
|
@ -313,8 +313,8 @@ bbstreamer_zstd_decompressor_content(bbstreamer *streamer,
|
|||
&mystreamer->zstd_outBuf, &inBuf);
|
||||
|
||||
if (ZSTD_isError(ret))
|
||||
pg_log_error("could not decompress data: %s",
|
||||
ZSTD_getErrorName(ret));
|
||||
pg_fatal("could not decompress data: %s",
|
||||
ZSTD_getErrorName(ret));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue