|
8 | 8 | * Portions Copyright (c) 1994, Regents of the University of California |
9 | 9 | * |
10 | 10 | * IDENTIFICATION |
11 | | - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.66 2010/04/19 17:54:48 tgl Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.67 2010/04/22 08:04:24 sriggs Exp $ |
12 | 12 | * |
13 | 13 | *------------------------------------------------------------------------- |
14 | 14 | */ |
@@ -578,9 +578,17 @@ btree_xlog_delete_get_latestRemovedXid(XLogRecord *record) |
578 | 578 | OffsetNumberhoffnum; |
579 | 579 | TransactionIdlatestRemovedXid=InvalidTransactionId; |
580 | 580 | TransactionIdhtupxid=InvalidTransactionId; |
581 | | -intnum_unused=0,num_redirect=0,num_dead=0; |
582 | 581 | inti; |
583 | 582 |
|
| 583 | +/* |
| 584 | + * If there's nothing running on the standby we don't need to derive |
| 585 | + * a full latestRemovedXid value, so use a fast path out of here. |
| 586 | + * That returns InvalidTransactionId, and so will conflict with |
| 587 | + * users, but since we just worked out that's zero people, its OK. |
| 588 | + */ |
| 589 | +if (CountDBBackends(InvalidOid)==0) |
| 590 | +returnlatestRemovedXid; |
| 591 | + |
584 | 592 | /* |
585 | 593 | * Get index page |
586 | 594 | */ |
@@ -629,7 +637,6 @@ btree_xlog_delete_get_latestRemovedXid(XLogRecord *record) |
629 | 637 | */ |
630 | 638 | while (ItemIdIsRedirected(hitemid)) |
631 | 639 | { |
632 | | -num_redirect++; |
633 | 640 | hoffnum=ItemIdGetRedirect(hitemid); |
634 | 641 | hitemid=PageGetItemId(hpage,hoffnum); |
635 | 642 | CHECK_FOR_INTERRUPTS(); |
@@ -662,25 +669,23 @@ btree_xlog_delete_get_latestRemovedXid(XLogRecord *record) |
662 | 669 | * marked on LP_NORMAL items. So we just ignore this item and move |
663 | 670 | * onto the next, for the purposes of calculating latestRemovedxids. |
664 | 671 | */ |
665 | | -num_dead++; |
666 | 672 | } |
667 | 673 | else |
668 | | -{ |
669 | 674 | Assert(!ItemIdIsUsed(hitemid)); |
670 | | -num_unused++; |
671 | | -} |
672 | 675 |
|
673 | 676 | UnlockReleaseBuffer(hbuffer); |
674 | 677 | } |
675 | 678 |
|
676 | 679 | UnlockReleaseBuffer(ibuffer); |
677 | 680 |
|
678 | | -Assert(num_unused==0); |
679 | | - |
680 | 681 | /* |
681 | 682 | * Note that if all heap tuples were LP_DEAD then we will be |
682 | | - * returning InvalidTransactionId here. This seems very unlikely |
683 | | - * in practice. |
| 683 | + * returning InvalidTransactionId here. That can happen if we are |
| 684 | + * re-replaying this record type, though that will be before the |
| 685 | + * consistency point and will not cause problems. It should |
| 686 | + * happen very rarely after the consistency point, though note |
| 687 | + * that we can't tell the difference between this and the fast |
| 688 | + * path exit above. May need to change that in future. |
684 | 689 | */ |
685 | 690 | returnlatestRemovedXid; |
686 | 691 | } |
@@ -963,13 +968,6 @@ btree_redo(XLogRecPtr lsn, XLogRecord *record) |
963 | 968 | TransactionIdlatestRemovedXid=btree_xlog_delete_get_latestRemovedXid(record); |
964 | 969 | xl_btree_delete*xlrec= (xl_btree_delete*)XLogRecGetData(record); |
965 | 970 |
|
966 | | -/* |
967 | | - * XXX Currently we put everybody on death row, because |
968 | | - * currently _bt_delitems() supplies InvalidTransactionId. |
969 | | - * This can be fairly painful, so providing a better value |
970 | | - * here is worth some thought and possibly some effort to |
971 | | - * improve. |
972 | | - */ |
973 | 971 | ResolveRecoveryConflictWithSnapshot(latestRemovedXid,xlrec->node); |
974 | 972 | } |
975 | 973 | break; |
|