No need to wait for idle-in-transaction sessions during index builds.

GetCurrentVirtualXIDs() specifically *includes* backends that have
proc->xmin == InvalidTransactionId (0), but I'm not sure why.

$SUBJECT is currently used by DefineIndex() to wait for all backends
that might be able to see index changes in phase 2 of concurrent index
build. The code comments say "we have to wait out any transactions that
might have older snapshots". If proc->xmin == 0 it is because they
haven't got any snapshots at all and therefore the index build does
*not* need to wait for them.

I'm using this routine for Hot Standby also, so patching this will allow
me to ignore idle-in-transaction sessions unless they are from
serializable transactions or have open cursors. But there's no need for
me to include this in the patch if its a general fix.

-- 
 Simon Riggs           www.2ndQuadrant.com
 PostgreSQL Training, Services and Support
Index: src/backend/storage/ipc/procarray.c
===================================================================
RCS file: /home/sriggs/pg/REPOSITORY/pgsql/src/backend/storage/ipc/procarray.c,v
retrieving revision 1.47
diff -c -r1.47 procarray.c
*** src/backend/storage/ipc/procarray.c	1 Jan 2009 17:23:47 -0000	1.47
--- src/backend/storage/ipc/procarray.c	16 Jan 2009 16:39:23 -0000
***************
*** 1023,1030 ****
   *
   * The array is palloc'd and is terminated with an invalid VXID.
   *
!  * If limitXmin is not InvalidTransactionId, we skip any backends
!  * with xmin >= limitXmin.	If allDbs is false, we skip backends attached
   * to other databases.  If excludeVacuum isn't zero, we skip processes for
   * which (excludeVacuum & vacuumFlags) is not zero.  Also, our own process
   * is always skipped.
--- 1023,1030 ----
   *
   * The array is palloc'd and is terminated with an invalid VXID.
   *
!  * If limitXmin is not InvalidTransactionId, we skip any backends with a 
!  * valid xmin >= limitXmin.	If allDbs is false, we skip backends attached
   * to other databases.  If excludeVacuum isn't zero, we skip processes for
   * which (excludeVacuum & vacuumFlags) is not zero.  Also, our own process
   * is always skipped.
***************
*** 1059,1069 ****
  			TransactionId pxmin = proc->xmin;
  
  			/*
! 			 * Note that InvalidTransactionId precedes all other XIDs, so a
! 			 * proc that hasn't set xmin yet will always be included.
  			 */
  			if (!TransactionIdIsValid(limitXmin) ||
! 				TransactionIdPrecedes(pxmin, limitXmin))
  			{
  				VirtualTransactionId vxid;
  
--- 1059,1070 ----
  			TransactionId pxmin = proc->xmin;
  
  			/*
! 			 * If we have a specific limitXmin then we need not include
! 			 * any procs with an unset xmin, since they have no snapshots
! 			 * older than limitXmin
  			 */
  			if (!TransactionIdIsValid(limitXmin) ||
! 				(TransactionIdIsValid(pxmin) && TransactionIdPrecedes(pxmin, limitXmin)))
  			{
  				VirtualTransactionId vxid;
  
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to