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

Commit08186dc

Browse files
committed
Move _bt_upgrademetapage() into critical section.
Any changes on page should be done in critical section, so move_bt_upgrademetapage into critical section. Improve comment. Found by AmitKapila during post-commit review of857f9c3.Author: Amit Kapila
1 parent3c9cf06 commit08186dc

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,10 +2150,6 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
21502150
metapg=BufferGetPage(metabuf);
21512151
metad=BTPageGetMeta(metapg);
21522152

2153-
/* upgrade metapage if needed */
2154-
if (metad->btm_version<BTREE_VERSION)
2155-
_bt_upgrademetapage(metapg);
2156-
21572153
/*
21582154
* Create downlink item for left page (old root). Since this will be the
21592155
* first item in a non-leaf page, it implicitly has minus-infinity key
@@ -2178,6 +2174,10 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
21782174
/* NO EREPORT(ERROR) from here till newroot op is logged */
21792175
START_CRIT_SECTION();
21802176

2177+
/* upgrade metapage if needed */
2178+
if (metad->btm_version<BTREE_VERSION)
2179+
_bt_upgrademetapage(metapg);
2180+
21812181
/* set btree special data */
21822182
rootopaque= (BTPageOpaque)PageGetSpecialPointer(rootpage);
21832183
rootopaque->btpo_prev=rootopaque->btpo_next=P_NONE;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,6 @@ _bt_getroot(Relation rel, int access)
341341
LockBuffer(metabuf,BUFFER_LOCK_UNLOCK);
342342
LockBuffer(metabuf,BT_WRITE);
343343

344-
/* upgrade metapage if needed */
345-
if (metad->btm_version<BTREE_VERSION)
346-
_bt_upgrademetapage(metapg);
347-
348344
/*
349345
* Race condition:if someone else initialized the metadata between
350346
* the time we released the read lock and acquired the write lock, we
@@ -379,6 +375,10 @@ _bt_getroot(Relation rel, int access)
379375
/* NO ELOG(ERROR) till meta is updated */
380376
START_CRIT_SECTION();
381377

378+
/* upgrade metapage if needed */
379+
if (metad->btm_version<BTREE_VERSION)
380+
_bt_upgrademetapage(metapg);
381+
382382
metad->btm_root=rootblkno;
383383
metad->btm_level=0;
384384
metad->btm_fastroot=rootblkno;

‎src/include/access/nbtree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ typedef struct BTMetaPageData
103103
BlockNumberbtm_fastroot;/* current "fast" root location */
104104
uint32btm_fastlevel;/* tree level of the "fast" root page */
105105
/* following fields are available since page version 3 */
106-
TransactionIdbtm_oldest_btpo_xact;/* oldest btpo_xact amongof deleted
106+
TransactionIdbtm_oldest_btpo_xact;/* oldest btpo_xact amongall deleted
107107
* pages */
108108
float8btm_last_cleanup_num_heap_tuples;/* number of heap tuples
109109
* during last cleanup */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp