Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5449d5b

Browse files
committed
Fix infinite wait when reading a partially written WAL record
If a crash occurs while writing a WAL record that spans multiple pages, therecovery process marks the page with the XLP_FIRST_IS_OVERWRITE_CONTRECORDflag. However, logical decoding currently attempts to read the full WALrecord based on its expected size before checking this flag, which can leadto an infinite wait if the remaining data is never written (e.g., no activityafter crash).This patch updates the logic first to read the page header and check forthe XLP_FIRST_IS_OVERWRITE_CONTRECORD flag before attempting to reconstructthe full WAL record. If the flag is set, decoding correctly identifiesthe record as incomplete and avoids waiting for WAL data that will neverarrive.Discussion:https://postgr.es/m/CAAKRu_ZCOzQpEumLFgG_%2Biw3FTa%2BhJ4SRpxzaQBYxxM_ZAzWcA%40mail.gmail.comDiscussion:https://postgr.es/m/CALDaNm34m36PDHzsU_GdcNXU0gLTfFY5rzh9GSQv%3Dw6B%2BQVNRQ%40mail.gmail.comAuthor: Vignesh C <vignesh21@gmail.com>Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com>Reviewed-by: Michael Paquier <michael@paquier.xyz>Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>Backpatch-through: 13
1 parent27c7c11 commit5449d5b

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

‎src/backend/access/transam/xlogreader.c‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -723,11 +723,12 @@ XLogDecodeNextRecord(XLogReaderState *state, bool nonblocking)
723723
/* Calculate pointer to beginning of next page */
724724
targetPagePtr+=XLOG_BLCKSZ;
725725

726-
/* Wait for the next page to become available */
727-
readOff=ReadPageInternal(state,targetPagePtr,
728-
Min(total_len-gotlen+SizeOfXLogShortPHD,
729-
XLOG_BLCKSZ));
730-
726+
/*
727+
* Read the page header before processing the record data, so we
728+
* can handle the case where the previous record ended as being a
729+
* partial one.
730+
*/
731+
readOff=ReadPageInternal(state,targetPagePtr,SizeOfXLogShortPHD);
731732
if (readOff==XLREAD_WOULDBLOCK)
732733
returnXLREAD_WOULDBLOCK;
733734
elseif (readOff<0)
@@ -776,6 +777,15 @@ XLogDecodeNextRecord(XLogReaderState *state, bool nonblocking)
776777
gotoerr;
777778
}
778779

780+
/* Wait for the next page to become available */
781+
readOff=ReadPageInternal(state,targetPagePtr,
782+
Min(total_len-gotlen+SizeOfXLogShortPHD,
783+
XLOG_BLCKSZ));
784+
if (readOff==XLREAD_WOULDBLOCK)
785+
returnXLREAD_WOULDBLOCK;
786+
elseif (readOff<0)
787+
gotoerr;
788+
779789
/* Append the continuation from this page to the buffer */
780790
pageHeaderSize=XLogPageHeaderSize(pageHeader);
781791

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp