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

Commit568995b

Browse files
committed
Avoid emitting a bogus WAL record when recycling an all-zero btree page.
Commitfafa374 caused _bt_getbuf() to possibly emit a WAL record fora page that it was about to recycle. However, it failed to distinguishall-zero pages from dead pages, which is important because only thelatter have valid btpo.xact values, or indeed any special space at all.Recycling an all-zero page with XLogStandbyInfoActive() enabled thereforeled to an Assert failure, or to emission of a WAL record containing abogus cutoff XID, which might lead to unnecessary query cancellationson hot standby servers.Per reports from Antonin Houska and 自己. Amit Kapila was first topropose this fix, and Robert Haas, myself, and Kyotaro Horiguchireviewed it at various times.This is an old bug, so back-patch to all supported branches.Discussion:https://postgr.es/m/2628.1474272158@localhostDiscussion:https://postgr.es/m/48875502.f4a0.1635f0c27b0.Coremail.zoulx1982@163.com
1 parentccc286d commit568995b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

‎src/backend/access/nbtree/nbtpage.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -622,9 +622,14 @@ _bt_getbuf(Relation rel, BlockNumber blkno, int access)
622622
/*
623623
* If we are generating WAL for Hot Standby then create a
624624
* WAL record that will allow us to conflict with queries
625-
* running on standby.
625+
* running on standby, in case they have snapshots older
626+
* than btpo.xact. This can only apply if the page does
627+
* have a valid btpo.xact value, ie not if it's new. (We
628+
* must check that because an all-zero page has no special
629+
* space.)
626630
*/
627-
if (XLogStandbyInfoActive()&&RelationNeedsWAL(rel))
631+
if (XLogStandbyInfoActive()&&RelationNeedsWAL(rel)&&
632+
!PageIsNew(page))
628633
{
629634
BTPageOpaqueopaque= (BTPageOpaque)PageGetSpecialPointer(page);
630635

@@ -737,7 +742,10 @@ _bt_pageinit(Page page, Size size)
737742
*_bt_page_recyclable() -- Is an existing page recyclable?
738743
*
739744
* This exists to make sure _bt_getbuf and btvacuumscan have the same
740-
* policy about whether a page is safe to re-use.
745+
* policy about whether a page is safe to re-use. But note that _bt_getbuf
746+
* knows enough to distinguish the PageIsNew condition from the other one.
747+
* At some point it might be appropriate to redesign this to have a three-way
748+
* result value.
741749
*/
742750
bool
743751
_bt_page_recyclable(Pagepage)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp