Fix assertion failure when running pgbench -s.
authorFujii Masao <[email protected]>
Thu, 7 Nov 2019 07:31:36 +0000 (16:31 +0900)
committerFujii Masao <[email protected]>
Thu, 7 Nov 2019 07:33:47 +0000 (16:33 +0900)
If there is the WAL page that the continuation WAL record just fits within
(i.e., the continuation record ends just at the end of the page) and
the LSN in such page is specified with -s option, previously pg_waldump
caused an assertion failure. The cause of this assertion failure was that
XLogFindNextRecord() that pg_waldump -s calls mistakenly handled
such special WAL page.

This commit changes XLogFindNextRecord() so that it can handle
such WAL page correctly.

Back-patch to all supported versions.

Author: Andrey Lepikhov
Reviewed-by: Fujii Masao, Michael Paquier
Discussion: https://postgr.es/m/99303554-5dd5-06e6-f943-b3005ccd6edd@postgrespro.ru

src/backend/access/transam/xlogreader.c

index 5a6cdae0e6b938910dd5ea45c004e2fa04dd5c5c..742ac30b5fa475f4332a2ca7bc0cfdc64738c028 100644 (file)
@@ -931,7 +931,7 @@ XLogFindNextRecord(XLogReaderState *state, XLogRecPtr RecPtr)
             *
             * Note that record headers are MAXALIGN'ed
             */
-           if (MAXALIGN(header->xlp_rem_len) > (XLOG_BLCKSZ - pageHeaderSize))
+           if (MAXALIGN(header->xlp_rem_len) >= (XLOG_BLCKSZ - pageHeaderSize))
                tmpRecPtr = targetPagePtr + XLOG_BLCKSZ;
            else
            {