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

Commit89f3973

Browse files
committed
Fix WAL format incompatibility introduced by backpatching of52ac6cd
52ac6cd added new field to ginxlogDeletePage and was backpatched to 9.4.That led to problems when patched postgres instance applies WAL recordsgenerated by non-patched one. WAL records generated by non-patched instancedon't contain new field, which patched one is expecting to see.Thankfully, we can distinguish patched and non-patched WAL records by their datasize. If we see that WAL record is generated by non-patched instance, we skipprocessing of new field. This commit comes with some assertions. Inparticular, if it appears that on some platform struct data size didn't changethen static assertion will trigger.Reported-by: Simon RiggsDiscussion:https://postgr.es/m/CANP8%2Bj%2BK4whxf7ET7%2BgO%2BG-baC3-WxqqH%3DnV4X2CgfEPA3Yu3g%40mail.gmail.comAuthor: Alexander KorotkovReviewed-by: Simon Riggs, Alvaro HerreraBackpatch-through: 9.4
1 parent7d7435c commit89f3973

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

‎src/backend/access/gin/ginxlog.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,24 @@ ginRedoDeletePage(XLogReaderState *record)
531531
page=BufferGetPage(dbuffer);
532532
Assert(GinPageIsData(page));
533533
GinPageGetOpaque(page)->flags=GIN_DELETED;
534-
GinPageSetDeleteXid(page,data->deleteXid);
534+
535+
/*
536+
* deleteXid field of ginxlogDeletePage was added during backpatching.
537+
* But, non-backpatched instances will continue generate WAL without
538+
* this field. We should be able to correctly apply that. We can
539+
* distinguish new WAL records by size their data, because
540+
* ginxlogDeletePage changes its size on both 32-bit and 64-bit
541+
* platforms.
542+
*/
543+
StaticAssertStmt(sizeof(ginxlogDeletePage)!=
544+
sizeof(ginxlogDeletePageOld),
545+
"ginxlogDeletePage size should be changed "
546+
"with addition of deleteXid field");
547+
Assert(XLogRecGetDataLen(record)==sizeof(ginxlogDeletePage)||
548+
XLogRecGetDataLen(record)==sizeof(ginxlogDeletePageOld));
549+
if (XLogRecGetDataLen(record)==sizeof(ginxlogDeletePage))
550+
GinPageSetDeleteXid(page,data->deleteXid);
551+
535552
PageSetLSN(page,lsn);
536553
MarkBufferDirty(dbuffer);
537554
}

‎src/include/access/ginxlog.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ typedef struct ginxlogDeletePage
161161
TransactionIddeleteXid;/* last Xid which could see this page in scan */
162162
}ginxlogDeletePage;
163163

164+
/*
165+
* Previous version of ginxlogDeletePage struct, which didn't have deleteXid
166+
* field. Used for size comparison (see ginRedoDeletePage()).
167+
*/
168+
typedefstructginxlogDeletePageOld
169+
{
170+
OffsetNumberparentOffset;
171+
BlockNumberrightLink;
172+
}ginxlogDeletePageOld;
173+
164174
#defineXLOG_GIN_UPDATE_META_PAGE 0x60
165175

166176
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp