@@ -2774,6 +2774,9 @@ FastPathTransferRelationLocks(LockMethod lockMethodTable, const LOCKTAG *locktag
2774
2774
Oid relid = locktag -> locktag_field2 ;
2775
2775
uint32 i ;
2776
2776
2777
+ /* fast-path group the lock belongs to */
2778
+ uint32 group = FAST_PATH_REL_GROUP (relid );
2779
+
2777
2780
/*
2778
2781
* Every PGPROC that can potentially hold a fast-path lock is present in
2779
2782
* ProcGlobal->allProcs. Prepared transactions are not, but any
@@ -2783,8 +2786,7 @@ FastPathTransferRelationLocks(LockMethod lockMethodTable, const LOCKTAG *locktag
2783
2786
for (i = 0 ; i < ProcGlobal -> allProcCount ; i ++ )
2784
2787
{
2785
2788
PGPROC * proc = & ProcGlobal -> allProcs [i ];
2786
- uint32 j ,
2787
- group ;
2789
+ uint32 j ;
2788
2790
2789
2791
LWLockAcquire (& proc -> fpInfoLock , LW_EXCLUSIVE );
2790
2792
@@ -2802,16 +2804,16 @@ FastPathTransferRelationLocks(LockMethod lockMethodTable, const LOCKTAG *locktag
2802
2804
* less clear that our backend is certain to have performed a memory
2803
2805
* fencing operation since the other backend set proc->databaseId. So
2804
2806
* for now, we test it after acquiring the LWLock just to be safe.
2807
+ *
2808
+ * Also skip groups without any registered fast-path locks.
2805
2809
*/
2806
- if (proc -> databaseId != locktag -> locktag_field1 )
2810
+ if (proc -> databaseId != locktag -> locktag_field1 ||
2811
+ proc -> fpLockBits [group ] == 0 )
2807
2812
{
2808
2813
LWLockRelease (& proc -> fpInfoLock );
2809
2814
continue ;
2810
2815
}
2811
2816
2812
- /* fast-path group the lock belongs to */
2813
- group = FAST_PATH_REL_GROUP (relid );
2814
-
2815
2817
for (j = 0 ; j < FP_LOCK_SLOTS_PER_GROUP ; j ++ )
2816
2818
{
2817
2819
uint32 lockmode ;
@@ -3027,6 +3029,9 @@ GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode, int *countp)
3027
3029
Oid relid = locktag -> locktag_field2 ;
3028
3030
VirtualTransactionId vxid ;
3029
3031
3032
+ /* fast-path group the lock belongs to */
3033
+ uint32 group = FAST_PATH_REL_GROUP (relid );
3034
+
3030
3035
/*
3031
3036
* Iterate over relevant PGPROCs. Anything held by a prepared
3032
3037
* transaction will have been transferred to the primary lock table,
@@ -3040,8 +3045,7 @@ GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode, int *countp)
3040
3045
for (i = 0 ; i < ProcGlobal -> allProcCount ; i ++ )
3041
3046
{
3042
3047
PGPROC * proc = & ProcGlobal -> allProcs [i ];
3043
- uint32 j ,
3044
- group ;
3048
+ uint32 j ;
3045
3049
3046
3050
/* A backend never blocks itself */
3047
3051
if (proc == MyProc )
@@ -3056,16 +3060,16 @@ GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode, int *countp)
3056
3060
*
3057
3061
* See FastPathTransferRelationLocks() for discussion of why we do
3058
3062
* this test after acquiring the lock.
3063
+ *
3064
+ * Also skip groups without any registered fast-path locks.
3059
3065
*/
3060
- if (proc -> databaseId != locktag -> locktag_field1 )
3066
+ if (proc -> databaseId != locktag -> locktag_field1 ||
3067
+ proc -> fpLockBits [group ] == 0 )
3061
3068
{
3062
3069
LWLockRelease (& proc -> fpInfoLock );
3063
3070
continue ;
3064
3071
}
3065
3072
3066
- /* fast-path group the lock belongs to */
3067
- group = FAST_PATH_REL_GROUP (relid );
3068
-
3069
3073
for (j = 0 ; j < FP_LOCK_SLOTS_PER_GROUP ; j ++ )
3070
3074
{
3071
3075
uint32 lockmask ;
0 commit comments