Skip to content

Commit 10a8ab5

Browse files
committed
Merge branch 'PGPRO9622_ptrack1_2' into PGPRO9_6
2 parents 65a7e1d + 214c007 commit 10a8ab5

File tree

15 files changed

+85
-3
lines changed

15 files changed

+85
-3
lines changed

src/backend/access/heap/pruneheap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "access/transam.h"
2020
#include "access/htup_details.h"
2121
#include "access/xlog.h"
22+
#include "access/ptrack.h"
2223
#include "catalog/catalog.h"
2324
#include "miscadmin.h"
2425
#include "pgstat.h"
@@ -228,6 +229,7 @@ heap_page_prune(Relation relation, Buffer buffer, TransactionId OldestXmin,
228229
}
229230

230231
/* Any error while applying the changes is critical */
232+
ptrack_add_block(relation, BufferGetBlockNumber(buffer));
231233
START_CRIT_SECTION();
232234

233235
/* Have we found any prunable items? */

src/backend/access/heap/ptrack.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "utils/inval.h"
2929
#include "utils/array.h"
3030
#include "utils/relfilenodemap.h"
31+
#include "utils/builtins.h"
3132
#include <unistd.h>
3233
#include <sys/stat.h>
3334

@@ -661,3 +662,13 @@ pg_ptrack_get_and_clear(PG_FUNCTION_ARGS)
661662

662663
PG_RETURN_BYTEA_P(ptrack_get_and_clear(PG_GETARG_OID(0), PG_GETARG_OID(1)));
663664
}
665+
666+
/*
667+
* Returns ptrack version currently in use.
668+
*/
669+
PG_FUNCTION_INFO_V1(ptrack_version);
670+
Datum
671+
ptrack_version(PG_FUNCTION_ARGS)
672+
{
673+
PG_RETURN_TEXT_P(cstring_to_text(PTRACK_VERSION));
674+
}

src/backend/access/heap/rewriteheap.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
#include "access/tuptoaster.h"
115115
#include "access/xact.h"
116116
#include "access/xloginsert.h"
117+
#include "access/ptrack.h"
117118

118119
#include "catalog/catalog.h"
119120

@@ -330,11 +331,15 @@ end_heap_rewrite(RewriteState state)
330331
if (state->rs_buffer_valid)
331332
{
332333
if (state->rs_use_wal)
334+
{
335+
/* Don't forget to set ptrack bit even if we're skipping bufmgr stage */
336+
ptrack_add_block_redo(state->rs_new_rel->rd_node, state->rs_blockno);
333337
log_newpage(&state->rs_new_rel->rd_node,
334338
MAIN_FORKNUM,
335339
state->rs_blockno,
336340
state->rs_buffer,
337341
true);
342+
}
338343
RelationOpenSmgr(state->rs_new_rel);
339344

340345
PageSetChecksumInplace(state->rs_buffer, state->rs_blockno);
@@ -679,11 +684,15 @@ raw_heap_insert(RewriteState state, HeapTuple tup)
679684

680685
/* XLOG stuff */
681686
if (state->rs_use_wal)
687+
{
688+
/* Don't forget to set ptrack bit even if we're skipping bufmgr stage */
689+
ptrack_add_block_redo(state->rs_new_rel->rd_node, state->rs_blockno);
682690
log_newpage(&state->rs_new_rel->rd_node,
683691
MAIN_FORKNUM,
684692
state->rs_blockno,
685693
page,
686694
true);
695+
}
687696

688697
/*
689698
* Now write the page. We say isTemp = true even if it's not a

src/backend/access/nbtree/nbtree.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "access/nbtree.h"
2222
#include "access/relscan.h"
2323
#include "access/xlog.h"
24+
#include "access/ptrack.h"
2425
#include "catalog/index.h"
2526
#include "commands/vacuum.h"
2627
#include "storage/indexfsm.h"
@@ -253,9 +254,13 @@ btbuildempty(Relation index)
253254
PageSetChecksumInplace(metapage, BTREE_METAPAGE);
254255
smgrwrite(index->rd_smgr, INIT_FORKNUM, BTREE_METAPAGE,
255256
(char *) metapage, true);
257+
258+
/* Don't forget to set ptrack bit even if we're skipping bufmgr stage */
259+
ptrack_add_block_redo(index->rd_smgr->smgr_rnode.node, BTREE_METAPAGE);
256260
log_newpage(&index->rd_smgr->smgr_rnode.node, INIT_FORKNUM,
257261
BTREE_METAPAGE, metapage, false);
258-
262+
/* Ensure rd_smgr is open (could have been closed by relcache flush!) */
263+
RelationOpenSmgr(index);
259264
/*
260265
* An immediate sync is required even if we xlog'd the page, because the
261266
* write did not go through shared_buffers and therefore a concurrent

src/backend/access/nbtree/nbtsort.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#include "access/nbtree.h"
7070
#include "access/xlog.h"
7171
#include "access/xloginsert.h"
72+
#include "access/ptrack.h"
7273
#include "miscadmin.h"
7374
#include "storage/smgr.h"
7475
#include "tcop/tcopprot.h"
@@ -276,8 +277,12 @@ _bt_blwritepage(BTWriteState *wstate, Page page, BlockNumber blkno)
276277
/* XLOG stuff */
277278
if (wstate->btws_use_wal)
278279
{
280+
/* Don't forget to set ptrack bit even if we're skipping bufmgr stage */
281+
ptrack_add_block_redo(wstate->index->rd_node, blkno);
279282
/* We use the heap NEWPAGE record type for this */
280283
log_newpage(&wstate->index->rd_node, MAIN_FORKNUM, blkno, page, true);
284+
/* Ensure rd_smgr is open (could have been closed by relcache flush!) */
285+
RelationOpenSmgr(wstate->index);
281286
}
282287

283288
/*

src/backend/access/spgist/spgdoinsert.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ addLeafTuple(Relation index, SpGistState *state, SpGistLeafTuple leafTuple,
215215
xlrec.nodeI = 0;
216216

217217
ptrack_add_block(index, BufferGetBlockNumber(current->buffer));
218+
if (parent->buffer)
219+
ptrack_add_block(index, BufferGetBlockNumber(parent->buffer));
218220
START_CRIT_SECTION();
219221

220222
if (current->offnum == InvalidOffsetNumber ||

src/backend/access/spgist/spginsert.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,13 @@ spgbuildempty(Relation index)
196196
log_newpage(&index->rd_smgr->smgr_rnode.node, INIT_FORKNUM,
197197
SPGIST_NULL_BLKNO, page, true);
198198

199+
/* Don't forget to set ptrack bit even if we're skipping bufmgr stage */
200+
ptrack_add_block_redo(index->rd_smgr->smgr_rnode.node, SPGIST_METAPAGE_BLKNO);
201+
ptrack_add_block_redo(index->rd_smgr->smgr_rnode.node, SPGIST_ROOT_BLKNO);
202+
ptrack_add_block_redo(index->rd_smgr->smgr_rnode.node, SPGIST_NULL_BLKNO);
203+
204+
/* Ensure rd_smgr is open (could have been closed by relcache flush!) */
205+
RelationOpenSmgr(index);
199206
/*
200207
* An immediate sync is required even if we xlog'd the pages, because the
201208
* writes did not go through shared buffers and therefore a concurrent

src/backend/access/transam/xlog.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "access/xloginsert.h"
3636
#include "access/xlogreader.h"
3737
#include "access/xlogutils.h"
38+
#include "access/ptrack.h"
3839
#include "catalog/catversion.h"
3940
#include "catalog/pg_control.h"
4041
#include "catalog/pg_database.h"
@@ -9479,6 +9480,11 @@ xlog_redo(XLogReaderState *record)
94799480
else if (info == XLOG_FPI || info == XLOG_FPI_FOR_HINT)
94809481
{
94819482
Buffer buffer;
9483+
RelFileNode rnode;
9484+
BlockNumber blkno;
9485+
9486+
XLogRecGetBlockTag(record, 0, &rnode, NULL, &blkno);
9487+
ptrack_add_block_redo(rnode, blkno);
94829488

94839489
/*
94849490
* Full-page image (FPI) records contain nothing else but a backup

src/backend/access/transam/xloginsert.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "access/xlog.h"
2424
#include "access/xlog_internal.h"
2525
#include "access/xloginsert.h"
26+
#include "access/ptrack.h"
2627
#include "catalog/pg_control.h"
2728
#include "common/pg_lzcompress.h"
2829
#include "miscadmin.h"

src/backend/access/transam/xlogutils.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,6 @@ CreateFakeRelcacheEntry(RelFileNode rnode)
550550
FakeRelCacheEntry fakeentry;
551551
Relation rel;
552552

553-
Assert(InRecovery);
554-
555553
/* Allocate the Relation struct and all related space in one block. */
556554
fakeentry = palloc0(sizeof(FakeRelCacheEntryData));
557555
rel = (Relation) fakeentry;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy