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

Commit4c11d2c

Browse files
committed
Flag index metapages as standard-format in xlog.c calls.
btree, hash, and bloom indexes all set up their metapages in standardformat (that is, with pd_lower and pd_upper correctly delimiting theunused area); but they mostly didn't inform the xlog routines of this.When calling log_newpage[_buffer], this is bad because it loses theopportunity to compress unused data out of the WAL record. Whencalling XLogRegisterBuffer, it's not such a performance problem becauseall of these call sites also use REGBUF_WILL_INIT, preventing an FPIimage from being written. But it's still a good idea to provide theflag when relevant, because that aids WAL consistency checking.This completes the project of getting all the in-core index AMs tohandle their metapage WAL operations similarly.Amit Kapila, reviewed by Michael PaquierDiscussion:https://postgr.es/m/0d273805-0e9e-ec1a-cb84-d4da400b8f85@lab.ntt.co.jp
1 parent1b89056 commit4c11d2c

File tree

6 files changed

+16
-13
lines changed

6 files changed

+16
-13
lines changed

‎contrib/bloom/blinsert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ blbuildempty(Relation index)
175175
smgrwrite(index->rd_smgr,INIT_FORKNUM,BLOOM_METAPAGE_BLKNO,
176176
(char*)metapage, true);
177177
log_newpage(&index->rd_smgr->smgr_rnode.node,INIT_FORKNUM,
178-
BLOOM_METAPAGE_BLKNO,metapage,false);
178+
BLOOM_METAPAGE_BLKNO,metapage,true);
179179

180180
/*
181181
* An immediate sync is required even if we xlog'd the page, because the

‎src/backend/access/hash/hashpage.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ _hash_init(Relation rel, double num_tuples, ForkNumber forkNum)
403403

404404
XLogBeginInsert();
405405
XLogRegisterData((char*)&xlrec,SizeOfHashInitMetaPage);
406-
XLogRegisterBuffer(0,metabuf,REGBUF_WILL_INIT);
406+
XLogRegisterBuffer(0,metabuf,REGBUF_WILL_INIT |REGBUF_STANDARD);
407407

408408
recptr=XLogInsert(RM_HASH_ID,XLOG_HASH_INIT_META_PAGE);
409409

@@ -592,8 +592,9 @@ _hash_init_metabuffer(Buffer buf, double num_tuples, RegProcedure procid,
592592
metap->hashm_firstfree=0;
593593

594594
/*
595-
* Set pd_lower just past the end of the metadata. This is to log full
596-
* page image of metapage in xloginsert.c.
595+
* Set pd_lower just past the end of the metadata. This is essential,
596+
* because without doing so, metadata will be lost if xlog.c compresses
597+
* the page.
597598
*/
598599
((PageHeader)page)->pd_lower=
599600
((char*)metap+sizeof(HashMetaPageData))- (char*)page;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ _bt_insertonpg(Relation rel,
898898
xlmeta.fastroot=metad->btm_fastroot;
899899
xlmeta.fastlevel=metad->btm_fastlevel;
900900

901-
XLogRegisterBuffer(2,metabuf,REGBUF_WILL_INIT);
901+
XLogRegisterBuffer(2,metabuf,REGBUF_WILL_INIT |REGBUF_STANDARD);
902902
XLogRegisterBufData(2, (char*)&xlmeta,sizeof(xl_btree_metadata));
903903

904904
xlinfo=XLOG_BTREE_INSERT_META;
@@ -2032,7 +2032,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
20322032

20332033
XLogRegisterBuffer(0,rootbuf,REGBUF_WILL_INIT);
20342034
XLogRegisterBuffer(1,lbuf,REGBUF_STANDARD);
2035-
XLogRegisterBuffer(2,metabuf,REGBUF_WILL_INIT);
2035+
XLogRegisterBuffer(2,metabuf,REGBUF_WILL_INIT |REGBUF_STANDARD);
20362036

20372037
md.root=rootblknum;
20382038
md.level=metad->btm_level;

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ _bt_initmetapage(Page page, BlockNumber rootbknum, uint32 level)
6565
metaopaque->btpo_flags=BTP_META;
6666

6767
/*
68-
* Set pd_lower just past the end of the metadata. This is not essential
69-
* but it makes the page look compressible to xlog.c.
68+
* Set pd_lower just past the end of the metadata. This is essential,
69+
* because without doing so, metadata will be lost if xlog.c compresses
70+
* the page.
7071
*/
7172
((PageHeader)page)->pd_lower=
7273
((char*)metad+sizeof(BTMetaPageData))- (char*)page;
@@ -241,7 +242,7 @@ _bt_getroot(Relation rel, int access)
241242

242243
XLogBeginInsert();
243244
XLogRegisterBuffer(0,rootbuf,REGBUF_WILL_INIT);
244-
XLogRegisterBuffer(2,metabuf,REGBUF_WILL_INIT);
245+
XLogRegisterBuffer(2,metabuf,REGBUF_WILL_INIT |REGBUF_STANDARD);
245246

246247
md.root=rootblkno;
247248
md.level=0;
@@ -1827,7 +1828,7 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty)
18271828

18281829
if (BufferIsValid(metabuf))
18291830
{
1830-
XLogRegisterBuffer(4,metabuf,REGBUF_WILL_INIT);
1831+
XLogRegisterBuffer(4,metabuf,REGBUF_WILL_INIT |REGBUF_STANDARD);
18311832

18321833
xlmeta.root=metad->btm_root;
18331834
xlmeta.level=metad->btm_level;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ btbuildempty(Relation index)
298298
smgrwrite(index->rd_smgr,INIT_FORKNUM,BTREE_METAPAGE,
299299
(char*)metapage, true);
300300
log_newpage(&index->rd_smgr->smgr_rnode.node,INIT_FORKNUM,
301-
BTREE_METAPAGE,metapage,false);
301+
BTREE_METAPAGE,metapage,true);
302302

303303
/*
304304
* An immediate sync is required even if we xlog'd the page, because the

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ _bt_restore_meta(XLogReaderState *record, uint8 block_id)
107107
pageop->btpo_flags=BTP_META;
108108

109109
/*
110-
* Set pd_lower just past the end of the metadata. This is not essential
111-
* but it makes the page look compressible to xlog.c.
110+
* Set pd_lower just past the end of the metadata. This is essential,
111+
* because without doing so, metadata will be lost if xlog.c compresses
112+
* the page.
112113
*/
113114
((PageHeader)metapg)->pd_lower=
114115
((char*)md+sizeof(BTMetaPageData))- (char*)metapg;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp