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

Commitf47b5e1

Browse files
committed
Remove btree page items after page unlink
Currently, page unlink leaves remaining items "as is", but replay ofcorresponding WAL-record re-initializes page leaving it with no items.For the sake of consistency, this commit makes primary delete all the itemsduring page unlink as well.Thanks to this change, we now don't mask contents of deleted btree page forWAL consistency checking.Discussion:https://postgr.es/m/CAPpHfdt_OTyQpXaPJcWzV2N-LNeNJseNB-K_A66qG%3DL518VTFw%40mail.gmail.comAuthor: Alexander KorotkovReviewed-by: Peter Geoghegan
1 parent0f76294 commitf47b5e1

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

‎contrib/amcheck/verify_nbtree.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2864,11 +2864,8 @@ palloc_btree_page(BtreeCheckState *state, BlockNumber blocknum)
28642864
* As noted at the beginning of _bt_binsrch(), an internal page must have
28652865
* children, since there must always be a negative infinity downlink
28662866
* (there may also be a highkey). In the case of non-rightmost leaf
2867-
* pages, there must be at least a highkey. Deleted pages on replica
2868-
* might contain no items, because page unlink re-initializes
2869-
* page-to-be-deleted. Deleted pages with no items might be on primary
2870-
* too due to preceding recovery, but on primary new deletions can't
2871-
* happen concurrently to amcheck.
2867+
* pages, there must be at least a highkey. The exceptions are deleted
2868+
* pages, which contain no items.
28722869
*
28732870
* This is correct when pages are half-dead, since internal pages are
28742871
* never half-dead, and leaf pages must have a high key when half-dead

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,6 +2058,7 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, BlockNumber scanblkno,
20582058
BTMetaPageData*metad=NULL;
20592059
ItemIditemid;
20602060
Pagepage;
2061+
PageHeaderheader;
20612062
BTPageOpaqueopaque;
20622063
boolrightsib_is_rightmost;
20632064
inttargetlevel;
@@ -2327,6 +2328,14 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, BlockNumber scanblkno,
23272328
opaque->btpo_flags |=BTP_DELETED;
23282329
opaque->btpo.xact=ReadNewTransactionId();
23292330

2331+
/*
2332+
* Remove the remaining tuples on the page. This keeps things simple for
2333+
* WAL consistency checking.
2334+
*/
2335+
header= (PageHeader)page;
2336+
header->pd_lower=SizeOfPageHeaderData;
2337+
header->pd_upper=header->pd_special;
2338+
23302339
/* And update the metapage, if needed */
23312340
if (BufferIsValid(metabuf))
23322341
{

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,15 +1051,7 @@ btree_mask(char *pagedata, BlockNumber blkno)
10511051

10521052
maskopaq= (BTPageOpaque)PageGetSpecialPointer(page);
10531053

1054-
if (P_ISDELETED(maskopaq))
1055-
{
1056-
/*
1057-
* Mask page content on a DELETED page since it will be re-initialized
1058-
* during replay. See btree_xlog_unlink_page() for details.
1059-
*/
1060-
mask_page_content(page);
1061-
}
1062-
elseif (P_ISLEAF(maskopaq))
1054+
if (P_ISLEAF(maskopaq))
10631055
{
10641056
/*
10651057
* In btree leaf pages, it is possible to modify the LP_FLAGS without

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp