On Thu, 2007-09-06 at 21:47 +0100, Simon Riggs wrote: > On Thu, 2007-09-06 at 15:55 -0400, Tom Lane wrote:
> > This would have been painful to fix in 8.2 but it seems relatively > > trivial in HEAD --- we just need another filter option in > > GetCurrentVirtualXIDs. Patch enclosed. Tested manually on same/different databases. No docs changed, nor test cases added. -- Simon Riggs 2ndQuadrant http://www.2ndQuadrant.com
Index: src/backend/commands/indexcmds.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/commands/indexcmds.c,v retrieving revision 1.163 diff -c -r1.163 indexcmds.c *** src/backend/commands/indexcmds.c 5 Sep 2007 18:10:47 -0000 1.163 --- src/backend/commands/indexcmds.c 6 Sep 2007 21:47:21 -0000 *************** *** 538,544 **** * missing older tuples. Also, GetCurrentVirtualXIDs never reports our * own vxid, so we need not check for that. */ ! old_snapshots = GetCurrentVirtualXIDs(ActiveSnapshot->xmax); while (VirtualTransactionIdIsValid(*old_snapshots)) { --- 538,544 ---- * missing older tuples. Also, GetCurrentVirtualXIDs never reports our * own vxid, so we need not check for that. */ ! old_snapshots = GetCurrentVirtualXIDs(ActiveSnapshot->xmax, false); while (VirtualTransactionIdIsValid(*old_snapshots)) { Index: src/backend/storage/ipc/procarray.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/storage/ipc/procarray.c,v retrieving revision 1.30 diff -c -r1.30 procarray.c *** src/backend/storage/ipc/procarray.c 5 Sep 2007 21:11:19 -0000 1.30 --- src/backend/storage/ipc/procarray.c 6 Sep 2007 21:47:22 -0000 *************** *** 892,900 **** * * If limitXmin is not InvalidTransactionId, we skip any backends * with xmin >= limitXmin. Also, our own process is always skipped. */ VirtualTransactionId * ! GetCurrentVirtualXIDs(TransactionId limitXmin) { VirtualTransactionId *vxids; ProcArrayStruct *arrayP = procArray; --- 892,901 ---- * * If limitXmin is not InvalidTransactionId, we skip any backends * with xmin >= limitXmin. Also, our own process is always skipped. + * Optionally, we can skip processes attached to different databases. */ VirtualTransactionId * ! GetCurrentVirtualXIDs(TransactionId limitXmin, bool allDbs) { VirtualTransactionId *vxids; ProcArrayStruct *arrayP = procArray; *************** *** 916,921 **** --- 917,925 ---- if (proc == MyProc) continue; + if (!allDbs && proc->databaseId != MyProc->databaseId) + continue; + /* * Note that InvalidTransactionId precedes all other XIDs, so a * proc that hasn't set xmin yet will always be included. Index: src/include/storage/procarray.h =================================================================== RCS file: /projects/cvsroot/pgsql/src/include/storage/procarray.h,v retrieving revision 1.15 diff -c -r1.15 procarray.h *** src/include/storage/procarray.h 5 Sep 2007 18:10:48 -0000 1.15 --- src/include/storage/procarray.h 6 Sep 2007 21:47:24 -0000 *************** *** 33,39 **** extern int BackendXidGetPid(TransactionId xid); extern bool IsBackendPid(int pid); ! extern VirtualTransactionId *GetCurrentVirtualXIDs(TransactionId limitXmin); extern int CountActiveBackends(void); extern int CountDBBackends(Oid databaseid); extern int CountUserBackends(Oid roleid); --- 33,39 ---- extern int BackendXidGetPid(TransactionId xid); extern bool IsBackendPid(int pid); ! extern VirtualTransactionId *GetCurrentVirtualXIDs(TransactionId limitXmin, bool allDbs); extern int CountActiveBackends(void); extern int CountDBBackends(Oid databaseid); extern int CountUserBackends(Oid roleid);
---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster