|
53 | 53 | #include "access/xlog.h"
|
54 | 54 | #include "access/xloginsert.h"
|
55 | 55 | #include "access/xlogutils.h"
|
| 56 | +#include "access/ptrack.h" |
56 | 57 | #include "catalog/catalog.h"
|
57 | 58 | #include "catalog/namespace.h"
|
58 | 59 | #include "commands/vacuum.h"
|
@@ -2425,6 +2426,7 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
|
2425 | 2426 | HeapTupleCopyEpochFromPage(heaptup, BufferGetPage(buffer));
|
2426 | 2427 |
|
2427 | 2428 | /* NO EREPORT(ERROR) from here till changes are logged */
|
| 2429 | + ptrack_add_block(relation, BufferGetBlockNumber(buffer)); |
2428 | 2430 | START_CRIT_SECTION();
|
2429 | 2431 |
|
2430 | 2432 | RelationPutHeapTuple(relation, buffer, heaptup,
|
@@ -2799,6 +2801,7 @@ freeze_single_heap_page(Relation relation, Buffer buffer)
|
2799 | 2801 | {
|
2800 | 2802 | int i;
|
2801 | 2803 |
|
| 2804 | + ptrack_add_block(relation, BufferGetBlockNumber(buffer)); |
2802 | 2805 | START_CRIT_SECTION();
|
2803 | 2806 |
|
2804 | 2807 | MarkBufferDirty(buffer);
|
@@ -3147,6 +3150,7 @@ heap_multi_insert(Relation relation, HeapTuple *tuples, int ntuples,
|
3147 | 3150 | heap_page_prepare_for_xid(relation, buffer, xid, false);
|
3148 | 3151 |
|
3149 | 3152 | /* NO EREPORT(ERROR) from here till changes are logged */
|
| 3153 | + ptrack_add_block(relation, BufferGetBlockNumber(buffer)); |
3150 | 3154 | START_CRIT_SECTION();
|
3151 | 3155 |
|
3152 | 3156 | /*
|
@@ -3675,6 +3679,7 @@ heap_delete(Relation relation, ItemPointer tid,
|
3675 | 3679 | (new_infomask & HEAP_XMAX_IS_MULTI) ? true : false);
|
3676 | 3680 | HeapTupleCopyEpochFromPage(&tp, page);
|
3677 | 3681 |
|
| 3682 | + ptrack_add_block(relation, BufferGetBlockNumber(buffer)); |
3678 | 3683 | START_CRIT_SECTION();
|
3679 | 3684 |
|
3680 | 3685 | /*
|
@@ -4423,6 +4428,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
|
4423 | 4428 | (infomask_lock_old_tuple & HEAP_XMAX_IS_MULTI) ? true : false);
|
4424 | 4429 | HeapTupleCopyEpochFromPage(&oldtup, page);
|
4425 | 4430 |
|
| 4431 | + ptrack_add_block(relation, BufferGetBlockNumber(buffer)); |
4426 | 4432 | START_CRIT_SECTION();
|
4427 | 4433 |
|
4428 | 4434 | /* Clear obsolete visibility flags ... */
|
@@ -4600,6 +4606,9 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
|
4600 | 4606 | HeapTupleCopyEpochFromPage(&oldtup, page);
|
4601 | 4607 |
|
4602 | 4608 | /* NO EREPORT(ERROR) from here till changes are logged */
|
| 4609 | + ptrack_add_block(relation, BufferGetBlockNumber(buffer)); |
| 4610 | + if (newbuf != buffer) |
| 4611 | + ptrack_add_block(relation, BufferGetBlockNumber(newbuf)); |
4603 | 4612 | START_CRIT_SECTION();
|
4604 | 4613 |
|
4605 | 4614 | /*
|
@@ -5610,6 +5619,7 @@ heap_lock_tuple(Relation relation, HeapTuple tuple,
|
5610 | 5619 | (new_infomask & HEAP_XMAX_IS_MULTI) ? true : false);
|
5611 | 5620 | HeapTupleCopyEpochFromPage(tuple, page);
|
5612 | 5621 |
|
| 5622 | + ptrack_add_block(relation, BufferGetBlockNumber(*buffer)); |
5613 | 5623 | START_CRIT_SECTION();
|
5614 | 5624 |
|
5615 | 5625 | /*
|
@@ -6355,6 +6365,7 @@ heap_lock_updated_tuple_rec(Relation rel, ItemPointer tid, TransactionId xid,
|
6355 | 6365 | (new_infomask & HEAP_XMAX_IS_MULTI) ? true : false);
|
6356 | 6366 | HeapTupleCopyEpochFromPage(&mytup, BufferGetPage(buf));
|
6357 | 6367 |
|
| 6368 | + ptrack_add_block(rel, BufferGetBlockNumber(buf)); |
6358 | 6369 | START_CRIT_SECTION();
|
6359 | 6370 |
|
6360 | 6371 | /* ... and set them */
|
@@ -6509,6 +6520,7 @@ heap_finish_speculative(Relation relation, HeapTuple tuple)
|
6509 | 6520 | "invalid speculative token constant");
|
6510 | 6521 |
|
6511 | 6522 | /* NO EREPORT(ERROR) from here till changes are logged */
|
| 6523 | + ptrack_add_block(relation, BufferGetBlockNumber(buffer)); |
6512 | 6524 | START_CRIT_SECTION();
|
6513 | 6525 |
|
6514 | 6526 | Assert(HeapTupleHeaderIsSpeculative(tuple->t_data));
|
@@ -6623,6 +6635,7 @@ heap_abort_speculative(Relation relation, HeapTuple tuple)
|
6623 | 6635 | * do anything special with infomask bits.
|
6624 | 6636 | */
|
6625 | 6637 |
|
| 6638 | + ptrack_add_block(relation, BufferGetBlockNumber(buffer)); |
6626 | 6639 | START_CRIT_SECTION();
|
6627 | 6640 |
|
6628 | 6641 | /*
|
@@ -6756,6 +6769,7 @@ heap_inplace_update(Relation relation, HeapTuple tuple)
|
6756 | 6769 | elog(ERROR, "wrong tuple length");
|
6757 | 6770 |
|
6758 | 6771 | /* NO EREPORT(ERROR) from here till changes are logged */
|
| 6772 | + ptrack_add_block(relation, BufferGetBlockNumber(buffer)); |
6759 | 6773 | START_CRIT_SECTION();
|
6760 | 6774 |
|
6761 | 6775 | memcpy((char *) htup + htup->t_hoff,
|
@@ -8463,6 +8477,7 @@ heap_xlog_clean(XLogReaderState *record)
|
8463 | 8477 | XLogRedoAction action;
|
8464 | 8478 |
|
8465 | 8479 | XLogRecGetBlockTag(record, 0, &rnode, NULL, &blkno);
|
| 8480 | + ptrack_add_block_redo(rnode, blkno); |
8466 | 8481 |
|
8467 | 8482 | /*
|
8468 | 8483 | * We're about to remove tuples. In Hot Standby mode, ensure that there's
|
@@ -8555,6 +8570,7 @@ heap_xlog_visible(XLogReaderState *record)
|
8555 | 8570 | XLogRedoAction action;
|
8556 | 8571 |
|
8557 | 8572 | XLogRecGetBlockTag(record, 1, &rnode, NULL, &blkno);
|
| 8573 | + ptrack_add_block_redo(rnode, blkno); |
8558 | 8574 |
|
8559 | 8575 | /*
|
8560 | 8576 | * If there are any Hot Standby transactions running that have an xmin
|
@@ -8665,6 +8681,11 @@ heap_xlog_freeze_page(XLogReaderState *record)
|
8665 | 8681 | TransactionId cutoff_xid = xlrec->cutoff_xid;
|
8666 | 8682 | Buffer buffer;
|
8667 | 8683 | int ntup;
|
| 8684 | + RelFileNode rnode; |
| 8685 | + BlockNumber blkno; |
| 8686 | + |
| 8687 | + XLogRecGetBlockTag(record, 0, &rnode, NULL, &blkno); |
| 8688 | + ptrack_add_block_redo(rnode, blkno); |
8668 | 8689 |
|
8669 | 8690 | /*
|
8670 | 8691 | * In Hot Standby mode, ensure that there's no queries running which still
|
@@ -8750,6 +8771,7 @@ heap_xlog_delete(XLogReaderState *record)
|
8750 | 8771 | ItemPointerData target_tid;
|
8751 | 8772 |
|
8752 | 8773 | XLogRecGetBlockTag(record, 0, &target_node, NULL, &blkno);
|
| 8774 | + ptrack_add_block_redo(target_node, blkno); |
8753 | 8775 | ItemPointerSetBlockNumber(&target_tid, blkno);
|
8754 | 8776 | ItemPointerSetOffsetNumber(&target_tid, xlrec->offnum);
|
8755 | 8777 |
|
@@ -8840,6 +8862,7 @@ heap_xlog_insert(XLogReaderState *record)
|
8840 | 8862 | xlrec = (xl_heap_insert *) rec_data;
|
8841 | 8863 |
|
8842 | 8864 | XLogRecGetBlockTag(record, 0, &target_node, NULL, &blkno);
|
| 8865 | + ptrack_add_block_redo(target_node, blkno); |
8843 | 8866 | ItemPointerSetBlockNumber(&target_tid, blkno);
|
8844 | 8867 | ItemPointerSetOffsetNumber(&target_tid, xlrec->offnum);
|
8845 | 8868 |
|
@@ -8974,6 +8997,7 @@ heap_xlog_multi_insert(XLogReaderState *record)
|
8974 | 8997 | xlrec = (xl_heap_multi_insert *) rec_data;
|
8975 | 8998 |
|
8976 | 8999 | XLogRecGetBlockTag(record, 0, &rnode, NULL, &blkno);
|
| 9000 | + ptrack_add_block_redo(rnode, blkno); |
8977 | 9001 |
|
8978 | 9002 | /*
|
8979 | 9003 | * The visibility map may need to be fixed even if the heap page is
|
@@ -9136,8 +9160,10 @@ heap_xlog_update(XLogReaderState *record, bool hot_update)
|
9136 | 9160 | oldtup.t_len = 0;
|
9137 | 9161 |
|
9138 | 9162 | XLogRecGetBlockTag(record, 0, &rnode, NULL, &newblk);
|
| 9163 | + ptrack_add_block_redo(rnode, newblk); |
9139 | 9164 | if (XLogRecGetBlockTag(record, 1, NULL, NULL, &oldblk))
|
9140 | 9165 | {
|
| 9166 | + ptrack_add_block_redo(rnode, oldblk); |
9141 | 9167 | /* HOT updates are never done across pages */
|
9142 | 9168 | Assert(!hot_update);
|
9143 | 9169 | }
|
@@ -9388,6 +9414,11 @@ heap_xlog_confirm(XLogReaderState *record)
|
9388 | 9414 | OffsetNumber offnum;
|
9389 | 9415 | ItemId lp = NULL;
|
9390 | 9416 | HeapTupleHeader htup;
|
| 9417 | + RelFileNode rnode; |
| 9418 | + BlockNumber blkno; |
| 9419 | + |
| 9420 | + XLogRecGetBlockTag(record, 0, &rnode, NULL, &blkno); |
| 9421 | + ptrack_add_block_redo(rnode, blkno); |
9391 | 9422 |
|
9392 | 9423 | if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO)
|
9393 | 9424 | {
|
@@ -9424,6 +9455,11 @@ heap_xlog_lock(XLogReaderState *record)
|
9424 | 9455 | OffsetNumber offnum;
|
9425 | 9456 | ItemId lp = NULL;
|
9426 | 9457 | HeapTupleHeader htup;
|
| 9458 | + RelFileNode rnode; |
| 9459 | + BlockNumber blkno; |
| 9460 | + |
| 9461 | + XLogRecGetBlockTag(record, 0, &rnode, NULL, &blkno); |
| 9462 | + ptrack_add_block_redo(rnode, blkno); |
9427 | 9463 |
|
9428 | 9464 | /*
|
9429 | 9465 | * The visibility map may need to be fixed even if the heap page is
|
@@ -9495,6 +9531,11 @@ heap_xlog_lock_updated(XLogReaderState *record)
|
9495 | 9531 | OffsetNumber offnum;
|
9496 | 9532 | ItemId lp = NULL;
|
9497 | 9533 | HeapTupleHeader htup;
|
| 9534 | + RelFileNode rnode; |
| 9535 | + BlockNumber blkno; |
| 9536 | + |
| 9537 | + XLogRecGetBlockTag(record, 0, &rnode, NULL, &blkno); |
| 9538 | + ptrack_add_block_redo(rnode, blkno); |
9498 | 9539 |
|
9499 | 9540 | xlrec = (xl_heap_lock_updated *) XLogRecGetData(record);
|
9500 | 9541 |
|
@@ -9557,6 +9598,11 @@ heap_xlog_inplace(XLogReaderState *record)
|
9557 | 9598 | HeapTupleHeader htup;
|
9558 | 9599 | uint32 oldlen;
|
9559 | 9600 | Size newlen;
|
| 9601 | + RelFileNode rnode; |
| 9602 | + BlockNumber blkno; |
| 9603 | + |
| 9604 | + XLogRecGetBlockTag(record, 0, &rnode, NULL, &blkno); |
| 9605 | + ptrack_add_block_redo(rnode, blkno); |
9560 | 9606 |
|
9561 | 9607 | if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO)
|
9562 | 9608 | {
|
@@ -9597,6 +9643,7 @@ heap_xlog_epoch_shift(XLogReaderState *record)
|
9597 | 9643 | RelFileNode target_node;
|
9598 | 9644 |
|
9599 | 9645 | XLogRecGetBlockTag(record, 0, &target_node, NULL, &blkno);
|
| 9646 | + ptrack_add_block_redo(target_node, blkno); |
9600 | 9647 |
|
9601 | 9648 | if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO)
|
9602 | 9649 | {
|
|
0 commit comments