This is an automated email from the ASF dual-hosted git repository.
yjhjstz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
The following commit(s) were added to refs/heads/main by this push:
new 55d2cacddbc Make XLogCompressBackupBlock fail gracefully instead of
PANIC on error
55d2cacddbc is described below
commit 55d2cacddbcfa1363a948e82fea3ded8fe247a86
Author: Jianghua Yang <[email protected]>
AuthorDate: Fri Jun 13 06:48:23 2025 +0800
Make XLogCompressBackupBlock fail gracefully instead of PANIC on error
Previously, XLogCompressBackupBlock() called elog(ERROR) on internal
compression failures (e.g., out-of-memory or ZSTD error). Since this
function is invoked inside a critical section during WAL record assembly,
any ERROR is promoted to PANIC, leading to an immediate backend crash.
This patch replaces elog(ERROR) with elog(LOG) and a boolean return value.
Callers now check the return status and fall back to storing the
uncompressed full-page image if compression fails. This preserves
robustness and aligns with the behavior introduced in PostgreSQL 18
---
src/backend/access/transam/xloginsert.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/backend/access/transam/xloginsert.c
b/src/backend/access/transam/xloginsert.c
index 839f5bc3e01..168ed8a5b6a 100644
--- a/src/backend/access/transam/xloginsert.c
+++ b/src/backend/access/transam/xloginsert.c
@@ -655,6 +655,8 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
cbimg.hole_length,
regbuf->compressed_page,
&compressed_len);
+ if (!is_compressed)
+ elog(LOG, "WAL compression failed,
using uncompressed image");
}
/*
@@ -879,7 +881,10 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset,
uint16 hole_length,
{
cxt = ZSTD_createCCtx();
if (!cxt)
- elog(ERROR, "out of memory");
+ {
+ elog(LOG, "out of memory");
+ return false;
+ }
}
len = ZSTD_compressCCtx(cxt,
@@ -888,8 +893,11 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset,
uint16 hole_length,
COMPRESS_LEVEL);
if (ZSTD_isError(len))
- elog(ERROR, "compression failed: %s uncompressed len %d",
+ {
+ elog(LOG, "compression failed: %s uncompressed len %d",
ZSTD_getErrorName(len), orig_len);
+ len = -1; /* failure */
+ }
/*
* We recheck the actual size even if ZSTD reports success and
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]