Content-Length: 490805 | pFad | http://github.com/tonybelloni/postgres/commit/4c11d2c559e76892156fd08d6a3cf5e1848a017f

35 Flag index metapages as standard-format in xlog.c calls. · tonybelloni/postgres@4c11d2c · GitHub
Skip to content

Commit 4c11d2c

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

File tree

6 files changed

+16
-13
lines changed

6 files changed

+16
-13
lines changed

contrib/bloom/blinsert.c

+1-1
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

+4-3
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

+2-2
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

+5-4
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

+1-1
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

+3-2
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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/tonybelloni/postgres/commit/4c11d2c559e76892156fd08d6a3cf5e1848a017f

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy