=== Applying patches on top of PostgreSQL commit ID fef6da9e9c8790fa915942af2ada190c33fcf98c === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Wed Jul 9 04:41:19 UTC 2025 On branch cf/5621 nothing to commit, working tree clean === using 'git am' to apply patch ./v3-0001-Compress-big-WAL-records.patch === Applying: Compress big WAL records .git/rebase-apply/patch:82: trailing whitespace. .git/rebase-apply/patch:89: trailing whitespace. .git/rebase-apply/patch:314: trailing whitespace. .git/rebase-apply/patch:781: trailing whitespace. else warning: 4 lines add whitespace errors. Using index info to reconstruct a base tree... M contrib/pg_walinspect/pg_walinspect.c M src/backend/access/rmgrdesc/xlogdesc.c M src/backend/access/transam/xlog.c M src/backend/access/transam/xloginsert.c M src/backend/access/transam/xlogreader.c M src/backend/utils/misc/guc_tables.c M src/backend/utils/misc/postgresql.conf.sample M src/include/access/xlog.h M src/include/access/xloginsert.h M src/include/pg_config_manual.h Falling back to patching base and 3-way merge... Auto-merging src/include/pg_config_manual.h Auto-merging src/include/access/xloginsert.h CONFLICT (content): Merge conflict in src/include/access/xloginsert.h Auto-merging src/include/access/xlog.h Auto-merging src/backend/utils/misc/postgresql.conf.sample Auto-merging src/backend/utils/misc/guc_tables.c Auto-merging src/backend/access/transam/xlogreader.c CONFLICT (content): Merge conflict in src/backend/access/transam/xlogreader.c Auto-merging src/backend/access/transam/xloginsert.c Auto-merging src/backend/access/transam/xlog.c Auto-merging src/backend/access/rmgrdesc/xlogdesc.c Auto-merging contrib/pg_walinspect/pg_walinspect.c error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 Compress big WAL records When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". Unstaged changes after reset: M contrib/pg_walinspect/pg_walinspect.c M src/backend/access/rmgrdesc/xlogdesc.c M src/backend/access/transam/xlog.c M src/backend/access/transam/xloginsert.c M src/backend/access/transam/xlogreader.c M src/backend/utils/misc/guc_tables.c M src/backend/utils/misc/postgresql.conf.sample M src/include/access/xlog.h M src/include/access/xloginsert.h M src/include/access/xlogreader.h M src/include/access/xlogrecord.h M src/include/pg_config_manual.h M src/test/recovery/t/026_overwrite_contrecord.pl === using patch(1) to apply patch ./v3-0001-Compress-big-WAL-records.patch === patching file contrib/pg_walinspect/pg_walinspect.c Hunk #1 succeeded at 314 (offset 3 lines). patching file src/backend/access/rmgrdesc/xlogdesc.c patching file src/backend/access/transam/xlog.c Hunk #2 succeeded at 727 (offset 11 lines). Hunk #3 succeeded at 1059 (offset 11 lines). patching file src/backend/access/transam/xloginsert.c Hunk #14 succeeded at 704 (offset 12 lines). Hunk #15 succeeded at 749 (offset 12 lines). Hunk #16 succeeded at 803 (offset 12 lines). Hunk #17 succeeded at 821 (offset 12 lines). Hunk #18 succeeded at 852 (offset 12 lines). Hunk #19 succeeded at 863 (offset 12 lines). Hunk #20 succeeded at 881 (offset 12 lines). Hunk #21 succeeded at 926 (offset 12 lines). Hunk #22 succeeded at 991 (offset 12 lines). Hunk #23 succeeded at 1014 (offset 12 lines). Hunk #24 succeeded at 1394 (offset 12 lines). patching file src/backend/access/transam/xlogreader.c Hunk #2 succeeded at 55 (offset 1 line). Hunk #3 succeeded at 173 (offset 1 line). Hunk #4 succeeded at 538 (offset 1 line). Hunk #5 succeeded at 650 (offset 1 line). Hunk #6 FAILED at 684. Hunk #7 succeeded at 706 (offset 1 line). Hunk #8 succeeded at 722 (offset 1 line). Hunk #9 succeeded at 752 (offset 1 line). Hunk #10 FAILED at 792. Hunk #11 succeeded at 841 (offset 1 line). Hunk #12 succeeded at 852 (offset 1 line). Hunk #13 succeeded at 871 (offset 1 line). Hunk #14 succeeded at 883 (offset 1 line). Hunk #15 succeeded at 906 (offset 1 line). Hunk #16 succeeded at 1695 (offset 10 lines). Hunk #17 succeeded at 1811 (offset 10 lines). Hunk #18 succeeded at 1926 (offset 10 lines). Hunk #19 FAILED at 1952. Hunk #20 succeeded at 2183 (offset 10 lines). Hunk #21 FAILED at 2194. 4 out of 21 hunks FAILED -- saving rejects to file src/backend/access/transam/xlogreader.c.rej patching file src/backend/utils/misc/guc_tables.c Hunk #1 succeeded at 3028 (offset 47 lines). patching file src/backend/utils/misc/postgresql.conf.sample Hunk #1 succeeded at 247 (offset 16 lines). patching file src/include/access/xlog.h patching file src/include/access/xloginsert.h Hunk #1 FAILED at 45. 1 out of 1 hunk FAILED -- saving rejects to file src/include/access/xloginsert.h.rej patching file src/include/access/xlogreader.h patching file src/include/access/xlogrecord.h patching file src/include/pg_config_manual.h patching file src/test/recovery/t/026_overwrite_contrecord.pl Unstaged changes after reset: M contrib/pg_walinspect/pg_walinspect.c M src/backend/access/rmgrdesc/xlogdesc.c M src/backend/access/transam/xlog.c M src/backend/access/transam/xloginsert.c M src/backend/access/transam/xlogreader.c M src/backend/utils/misc/guc_tables.c M src/backend/utils/misc/postgresql.conf.sample M src/include/access/xlog.h M src/include/access/xlogreader.h M src/include/access/xlogrecord.h M src/include/pg_config_manual.h M src/test/recovery/t/026_overwrite_contrecord.pl Removing src/backend/access/transam/xlogreader.c.rej Removing src/include/access/xloginsert.h.rej === using 'git apply' to apply patch ./v3-0001-Compress-big-WAL-records.patch === /work/patches/./v3-0001-Compress-big-WAL-records.patch:88: trailing whitespace. /work/patches/./v3-0001-Compress-big-WAL-records.patch:95: trailing whitespace. /work/patches/./v3-0001-Compress-big-WAL-records.patch:320: trailing whitespace. /work/patches/./v3-0001-Compress-big-WAL-records.patch:787: trailing whitespace. else Applied patch to 'contrib/pg_walinspect/pg_walinspect.c' cleanly. Applied patch to 'src/backend/access/rmgrdesc/xlogdesc.c' cleanly. Applied patch to 'src/backend/access/transam/xlog.c' cleanly. Applied patch to 'src/backend/access/transam/xloginsert.c' cleanly. Applied patch to 'src/backend/access/transam/xlogreader.c' with conflicts. Applied patch to 'src/backend/utils/misc/guc_tables.c' cleanly. Applied patch to 'src/backend/utils/misc/postgresql.conf.sample' cleanly. Applied patch to 'src/include/access/xlog.h' cleanly. Applied patch to 'src/include/access/xloginsert.h' with conflicts. Applied patch to 'src/include/access/xlogreader.h' cleanly. Applied patch to 'src/include/access/xlogrecord.h' cleanly. Applied patch to 'src/include/pg_config_manual.h' cleanly. Applied patch to 'src/test/recovery/t/026_overwrite_contrecord.pl' cleanly. U src/backend/access/transam/xlogreader.c U src/include/access/xloginsert.h warning: 4 lines add whitespace errors. diff --cc src/backend/access/transam/xlogreader.c index ac1f801b1eb,558f40c1fa1..00000000000 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@@ -664,12 -690,12 +691,12 @@@ restart else { /* There may be no next page if it's too small. */ - if (total_len < SizeOfXLogRecord) + if (total_len_phisical < SizeOfXLogRecord) { report_invalid_record(state, - "invalid record length at %X/%X: expected at least %u, got %u", + "invalid record length at %X/%08X: expected at least %u, got %u", LSN_FORMAT_ARGS(RecPtr), - (uint32) SizeOfXLogRecord, total_len); + (uint32) SizeOfXLogRecord, total_len_phisical); goto err; } /* We'll validate the header once we have the next page. */ @@@ -766,12 -794,12 +795,12 @@@ * we expect there to be left. */ if (pageHeader->xlp_rem_len == 0 || - total_len != (pageHeader->xlp_rem_len + gotlen)) + total_len_phisical != (pageHeader->xlp_rem_len + gotlen)) { report_invalid_record(state, - "invalid contrecord length %u (expected %lld) at %X/%X", + "invalid contrecord length %u (expected %lld) at %X/%08X", pageHeader->xlp_rem_len, - ((long long) total_len) - gotlen, + ((long long) total_len_phisical) - gotlen, LSN_FORMAT_ARGS(RecPtr)); goto err; } @@@ -1847,19 -1955,6 +1965,22 @@@ DecodeXLogRecord(XLogReaderState *state } /* ++<<<<<<< ours + * Cross-check that bimg_len < BLCKSZ if it is compressed. + */ + if (BKPIMAGE_COMPRESSED(blk->bimg_info) && + blk->bimg_len == BLCKSZ) + { + report_invalid_record(state, + "BKPIMAGE_COMPRESSED set, but block image length %u at %X/%08X", + (unsigned int) blk->bimg_len, + LSN_FORMAT_ARGS(state->ReadRecPtr)); + goto err; + } + + /* ++======= ++>>>>>>> theirs * cross-check that bimg_len = BLCKSZ if neither HAS_HOLE is * set nor COMPRESSED(). */ @@@ -1867,8 -1962,7 +1988,11 @@@ blk->bimg_len != BLCKSZ) { report_invalid_record(state, ++<<<<<<< ours + "neither BKPIMAGE_HAS_HOLE nor BKPIMAGE_COMPRESSED set, but block image length is %u at %X/%08X", ++======= + "BKPIMAGE_HAS_HOLE is not set, but block image length is %u at %X/%X", ++>>>>>>> theirs (unsigned int) blk->data_len, LSN_FORMAT_ARGS(state->ReadRecPtr)); goto err; @@@ -2089,67 -2182,6 +2212,70 @@@ RestoreBlockImage(XLogReaderState *reco bkpb = &record->record->blocks[block_id]; ptr = bkpb->bkp_image; ++<<<<<<< ours + if (BKPIMAGE_COMPRESSED(bkpb->bimg_info)) + { + /* If a backup block image is compressed, decompress it */ + bool decomp_success = true; + + if ((bkpb->bimg_info & BKPIMAGE_COMPRESS_PGLZ) != 0) + { + if (pglz_decompress(ptr, bkpb->bimg_len, tmp.data, + BLCKSZ - bkpb->hole_length, true) < 0) + decomp_success = false; + } + else if ((bkpb->bimg_info & BKPIMAGE_COMPRESS_LZ4) != 0) + { +#ifdef USE_LZ4 + if (LZ4_decompress_safe(ptr, tmp.data, + bkpb->bimg_len, BLCKSZ - bkpb->hole_length) <= 0) + decomp_success = false; +#else + report_invalid_record(record, "could not restore image at %X/%08X compressed with %s not supported by build, block %d", + LSN_FORMAT_ARGS(record->ReadRecPtr), + "LZ4", + block_id); + return false; +#endif + } + else if ((bkpb->bimg_info & BKPIMAGE_COMPRESS_ZSTD) != 0) + { +#ifdef USE_ZSTD + size_t decomp_result = ZSTD_decompress(tmp.data, + BLCKSZ - bkpb->hole_length, + ptr, bkpb->bimg_len); + + if (ZSTD_isError(decomp_result)) + decomp_success = false; +#else + report_invalid_record(record, "could not restore image at %X/%08X compressed with %s not supported by build, block %d", + LSN_FORMAT_ARGS(record->ReadRecPtr), + "zstd", + block_id); + return false; +#endif + } + else + { + report_invalid_record(record, "could not restore image at %X/%08X compressed with unknown method, block %d", + LSN_FORMAT_ARGS(record->ReadRecPtr), + block_id); + return false; + } + + if (!decomp_success) + { + report_invalid_record(record, "could not decompress image at %X/%08X, block %d", + LSN_FORMAT_ARGS(record->ReadRecPtr), + block_id); + return false; + } + + ptr = tmp.data; + } + ++======= ++>>>>>>> theirs /* generate page, taking into account hole if necessary */ if (bkpb->hole_length == 0) { diff --cc src/include/access/xloginsert.h index d6a71415d4f,497bd89b91c..00000000000 --- a/src/include/access/xloginsert.h +++ b/src/include/access/xloginsert.h @@@ -44,9 -44,9 +44,14 @@@ extern void XLogBeginInsert(void); extern void XLogSetRecordFlags(uint8 flags); extern XLogRecPtr XLogInsert(RmgrId rmid, uint8 info); +extern XLogRecPtr XLogSimpleInsertInt64(RmgrId rmid, uint8 info, int64 value); extern void XLogEnsureRecordSpace(int max_block_id, int ndatas); ++<<<<<<< ours +extern void XLogRegisterData(const void *data, uint32 len); ++======= + extern void XLogEnsureCompressionBuffer(uint32 extraLen); + extern void XLogRegisterData(const char *data, uint32 len); ++>>>>>>> theirs extern void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags); extern void XLogRegisterBlock(uint8 block_id, RelFileLocator *rlocator, ForkNumber forknum, BlockNumber blknum, const PageData *page,