11
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.184 2009/04/04 17:40:36 tgl Exp $
11
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.185 2009/06/11 14:48:55 momjian Exp $
13
13
*-------------------------------------------------------------------------
639
639
* We can exclude any running transactions that have xmin > the xmin of
640
640
* our reference snapshot; their oldest snapshot must be newer than ours.
641
641
* We can also exclude any transactions that have xmin = zero, since they
642
* evidently have no live snapshot at all (and any one they might be
643
* in process of taking is certainly newer than ours). Transactions in
644
* other DBs can be ignored too, since they'll never even be able to see
642
* evidently have no live snapshot at all (and any one they might be in
643
* process of taking is certainly newer than ours). Transactions in other
644
* DBs can be ignored too, since they'll never even be able to see this
647
647
* We can also exclude autovacuum processes and processes running manual
648
648
* lazy VACUUMs, because they won't be fazed by missing index entries
649
* either. (Manual ANALYZEs, however, can't be excluded because they
649
* either. (Manual ANALYZEs, however, can't be excluded because they
650
650
* might be within transactions that are going to do arbitrary operations
653
653
* Also, GetCurrentVirtualXIDs never reports our own vxid, so we need not
654
654
* check for that.
656
* If a process goes idle-in-transaction with xmin zero, we do not need
657
* to wait for it anymore, per the above argument. We do not have the
658
* infrastructure right now to stop waiting if that happens, but we can
659
* at least avoid the folly of waiting when it is idle at the time we
660
* would begin to wait. We do this by repeatedly rechecking the output of
656
* If a process goes idle-in-transaction with xmin zero, we do not need to
657
* wait for it anymore, per the above argument. We do not have the
658
* infrastructure right now to stop waiting if that happens, but we can at
659
* least avoid the folly of waiting when it is idle at the time we would
660
* begin to wait. We do this by repeatedly rechecking the output of
661
661
* GetCurrentVirtualXIDs. If, during any iteration, a particular vxid
662
662
* doesn't show up in the output, we know we can forget about it.
681
681
newer_snapshots = GetCurrentVirtualXIDs(snapshot->xmin,
683
PROC_IS_AUTOVACUUM | PROC_IN_VACUUM,
683
PROC_IS_AUTOVACUUM | PROC_IN_VACUUM,
684
684
&n_newer_snapshots);
685
685
for (j = i; j < n_old_snapshots; j++)
687
687
if (!VirtualTransactionIdIsValid(old_snapshots[j]))
688
continue; /* found uninteresting in previous cycle */
688
continue; /* found uninteresting in previous cycle */
689
689
for (k = 0; k < n_newer_snapshots; k++)
691
691
if (VirtualTransactionIdEquals(old_snapshots[j],