File tree 2 files changed +14
-6
lines changed
2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change 8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.176 2007/02/01 19:10:28 momjian Exp $
11
+ * $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.177 2007/07/16 21:09:50 tgl Exp $
12
12
*
13
13
* NOTES
14
14
* A lock table is a shared memory hash table. When
@@ -2119,7 +2119,13 @@ GetLockStatusData(void)
2119
2119
el ++ ;
2120
2120
}
2121
2121
2122
- /* And release locks */
2122
+ /*
2123
+ * And release locks. We do this in reverse order for two reasons:
2124
+ * (1) Anyone else who needs more than one of the locks will be trying
2125
+ * to lock them in increasing order; we don't want to release the other
2126
+ * process until it can get all the locks it needs.
2127
+ * (2) This avoids O(N^2) behavior inside LWLockRelease.
2128
+ */
2123
2129
for (i = NUM_LOCK_PARTITIONS ; -- i >= 0 ;)
2124
2130
LWLockRelease (FirstLockMgrLock + i );
2125
2131
Original file line number Diff line number Diff line change 8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.190 2007/06/19 22:01:15 tgl Exp $
11
+ * $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.191 2007/07/16 21:09:50 tgl Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -1168,9 +1168,11 @@ CheckDeadLock(void)
1168
1168
}
1169
1169
1170
1170
/*
1171
- * Release locks acquired at head of routine. Order is not critical, so
1172
- * do it back-to-front to avoid waking another CheckDeadLock instance
1173
- * before it can get all the locks.
1171
+ * And release locks. We do this in reverse order for two reasons:
1172
+ * (1) Anyone else who needs more than one of the locks will be trying
1173
+ * to lock them in increasing order; we don't want to release the other
1174
+ * process until it can get all the locks it needs.
1175
+ * (2) This avoids O(N^2) behavior inside LWLockRelease.
1174
1176
*/
1175
1177
check_done :
1176
1178
for (i = NUM_LOCK_PARTITIONS ; -- i >= 0 ;)
You can’t perform that action at this time.
0 commit comments