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

Commit86bcaf6

Browse files
committed
brin ptrack with xlog
1 parent132c495 commit86bcaf6

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed

‎src/backend/access/brin/brin.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include"access/reloptions.h"
2323
#include"access/relscan.h"
2424
#include"access/xloginsert.h"
25+
#include"access/ptrack.h"
2526
#include"catalog/index.h"
2627
#include"catalog/pg_am.h"
2728
#include"miscadmin.h"
@@ -685,6 +686,7 @@ brinbuildempty(Relation index)
685686
LockBuffer(metabuf,BUFFER_LOCK_EXCLUSIVE);
686687

687688
/* Initialize and xlog metabuffer. */
689+
ptrack_add_block(index,BufferGetBlockNumber(metabuf));
688690
START_CRIT_SECTION();
689691
brin_metapage_init(BufferGetPage(metabuf),BrinGetPagesPerRange(index),
690692
BRIN_CURRENT_VERSION);

‎src/backend/access/brin/brin_pageops.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include"access/brin_revmap.h"
1616
#include"access/brin_xlog.h"
1717
#include"access/xloginsert.h"
18+
#include"access/ptrack.h"
1819
#include"miscadmin.h"
1920
#include"storage/bufmgr.h"
2021
#include"storage/freespace.h"
@@ -177,6 +178,7 @@ brin_doupdate(Relation idxrel, BlockNumber pagesPerRange,
177178
UnlockReleaseBuffer(newbuf);
178179
}
179180

181+
ptrack_add_block(idxrel,BufferGetBlockNumber(oldbuf));
180182
START_CRIT_SECTION();
181183
PageIndexDeleteNoCompact(oldpage,&oldoff,1);
182184
if (PageAddItemExtended(oldpage, (Item)newtup,newsz,oldoff,
@@ -237,6 +239,9 @@ brin_doupdate(Relation idxrel, BlockNumber pagesPerRange,
237239

238240
revmapbuf=brinLockRevmapPageForUpdate(revmap,heapBlk);
239241

242+
ptrack_add_block(idxrel,BufferGetBlockNumber(newbuf));
243+
ptrack_add_block(idxrel,BufferGetBlockNumber(oldbuf));
244+
ptrack_add_block(idxrel,BufferGetBlockNumber(revmapbuf));
240245
START_CRIT_SECTION();
241246

242247
/*
@@ -408,6 +413,8 @@ brin_doinsert(Relation idxrel, BlockNumber pagesPerRange,
408413
blk=BufferGetBlockNumber(*buffer);
409414

410415
/* Execute the actual insertion */
416+
ptrack_add_block(idxrel,BufferGetBlockNumber(*buffer));
417+
ptrack_add_block(idxrel,BufferGetBlockNumber(revmapbuf));
411418
START_CRIT_SECTION();
412419
if (extended)
413420
brin_page_init(BufferGetPage(*buffer),BRIN_PAGETYPE_REGULAR);
@@ -862,6 +869,7 @@ brin_initialize_empty_new_buffer(Relation idxrel, Buffer buffer)
862869
"brin_initialize_empty_new_buffer: initializing blank page %u",
863870
BufferGetBlockNumber(buffer)));
864871

872+
ptrack_add_block(idxrel,BufferGetBlockNumber(buffer));
865873
START_CRIT_SECTION();
866874
page=BufferGetPage(buffer);
867875
brin_page_init(page,BRIN_PAGETYPE_REGULAR);

‎src/backend/access/brin/brin_revmap.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include"access/brin_xlog.h"
2828
#include"access/rmgr.h"
2929
#include"access/xloginsert.h"
30+
#include"access/ptrack.h"
3031
#include"miscadmin.h"
3132
#include"storage/bufmgr.h"
3233
#include"storage/lmgr.h"
@@ -475,6 +476,8 @@ revmap_physical_extend(BrinRevmap *revmap)
475476
* Ok, we have now locked the metapage and the target block. Re-initialize
476477
* it as a revmap page.
477478
*/
479+
ptrack_add_block(irel,BufferGetBlockNumber(buf));
480+
ptrack_add_block(irel,BufferGetBlockNumber(revmap->rm_metaBuf));
478481
START_CRIT_SECTION();
479482

480483
/* the rm_tids array is initialized to all invalid by PageInit */

‎src/backend/access/brin/brin_xlog.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include"access/brin_pageops.h"
1515
#include"access/brin_xlog.h"
1616
#include"access/xlogutils.h"
17+
#include"access/ptrack.h"
1718

1819

1920
/*
@@ -26,6 +27,11 @@ brin_xlog_createidx(XLogReaderState *record)
2627
xl_brin_createidx*xlrec= (xl_brin_createidx*)XLogRecGetData(record);
2728
Bufferbuf;
2829
Pagepage;
30+
RelFileNodernode;
31+
BlockNumberblkno;
32+
33+
XLogRecGetBlockTag(record,0,&rnode,NULL,&blkno);
34+
ptrack_add_block_redo(rnode,blkno);
2935

3036
/* create the index' metapage */
3137
buf=XLogInitBufferForRedo(record,0);
@@ -50,6 +56,13 @@ brin_xlog_insert_update(XLogReaderState *record,
5056
BlockNumberregpgno;
5157
Pagepage;
5258
XLogRedoActionaction;
59+
RelFileNodernode;
60+
BlockNumberblkno;
61+
62+
XLogRecGetBlockTag(record,0,&rnode,NULL,&blkno);
63+
ptrack_add_block_redo(rnode,blkno);
64+
XLogRecGetBlockTag(record,1,&rnode,NULL,&blkno);
65+
ptrack_add_block_redo(rnode,blkno);
5366

5467
/*
5568
* If we inserted the first and only tuple on the page, re-initialize the
@@ -137,9 +150,15 @@ brin_xlog_update(XLogReaderState *record)
137150
xl_brin_update*xlrec= (xl_brin_update*)XLogRecGetData(record);
138151
Bufferbuffer;
139152
XLogRedoActionaction;
153+
RelFileNodernode;
154+
BlockNumberblkno;
155+
156+
XLogRecGetBlockTag(record,2,&rnode,NULL,&blkno);
157+
ptrack_add_block_redo(rnode,blkno);
140158

141159
/* First remove the old tuple */
142160
action=XLogReadBufferForRedo(record,2,&buffer);
161+
143162
if (action==BLK_NEEDS_REDO)
144163
{
145164
Pagepage;
@@ -174,9 +193,15 @@ brin_xlog_samepage_update(XLogReaderState *record)
174193
xl_brin_samepage_update*xlrec;
175194
Bufferbuffer;
176195
XLogRedoActionaction;
196+
RelFileNodernode;
197+
BlockNumberblkno;
198+
199+
XLogRecGetBlockTag(record,0,&rnode,NULL,&blkno);
200+
ptrack_add_block_redo(rnode,blkno);
177201

178202
xlrec= (xl_brin_samepage_update*)XLogRecGetData(record);
179203
action=XLogReadBufferForRedo(record,0,&buffer);
204+
180205
if (action==BLK_NEEDS_REDO)
181206
{
182207
Sizetuplen;
@@ -220,14 +245,21 @@ brin_xlog_revmap_extend(XLogReaderState *record)
220245
Pagepage;
221246
BlockNumbertargetBlk;
222247
XLogRedoActionaction;
248+
RelFileNodernode;
249+
BlockNumberblkno;
223250

224251
xlrec= (xl_brin_revmap_extend*)XLogRecGetData(record);
225252

226-
XLogRecGetBlockTag(record,1,NULL,NULL,&targetBlk);
253+
XLogRecGetBlockTag(record,0,&rnode,NULL,&blkno);
254+
ptrack_add_block_redo(rnode,blkno);
255+
XLogRecGetBlockTag(record,1,&rnode,NULL,&targetBlk);
256+
ptrack_add_block_redo(rnode,targetBlk);
257+
227258
Assert(xlrec->targetBlk==targetBlk);
228259

229260
/* Update the metapage */
230261
action=XLogReadBufferForRedo(record,0,&metabuf);
262+
231263
if (action==BLK_NEEDS_REDO)
232264
{
233265
Pagemetapg;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp