Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbadb83f

Browse files
committed
If we're going to have a non-panic check for held_lwlocks[] overrun,
it must occur *before* we get into the critical state of holding alock we have no place to record. Per discussion with Qingqing Zhou.
1 parente794dfa commitbadb83f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

‎src/backend/storage/lmgr/lwlock.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Portions Copyright (c) 1994, Regents of the University of California
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.26 2005/04/0803:43:54 tgl Exp $
18+
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.27 2005/04/0814:18:35 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -213,6 +213,10 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode)
213213
*/
214214
Assert(!(proc==NULL&&IsUnderPostmaster));
215215

216+
/* Ensure we will have room to remember the lock */
217+
if (num_held_lwlocks >=MAX_SIMUL_LWLOCKS)
218+
elog(ERROR,"too many LWLocks taken");
219+
216220
/*
217221
* Lock out cancel/die interrupts until we exit the code section
218222
* protected by the LWLock. This ensures that interrupts will not
@@ -328,8 +332,6 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode)
328332
SpinLockRelease_NoHoldoff(&lock->mutex);
329333

330334
/* Add lock to list of locks held by this backend */
331-
if (num_held_lwlocks >=MAX_SIMUL_LWLOCKS)
332-
elog(ERROR,"too many LWLocks taken");
333335
held_lwlocks[num_held_lwlocks++]=lockid;
334336

335337
/*
@@ -354,6 +356,10 @@ LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode)
354356

355357
PRINT_LWDEBUG("LWLockConditionalAcquire",lockid,lock);
356358

359+
/* Ensure we will have room to remember the lock */
360+
if (num_held_lwlocks >=MAX_SIMUL_LWLOCKS)
361+
elog(ERROR,"too many LWLocks taken");
362+
357363
/*
358364
* Lock out cancel/die interrupts until we exit the code section
359365
* protected by the LWLock. This ensures that interrupts will not
@@ -398,8 +404,6 @@ LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode)
398404
else
399405
{
400406
/* Add lock to list of locks held by this backend */
401-
if (num_held_lwlocks >=MAX_SIMUL_LWLOCKS)
402-
elog(ERROR,"too many LWLocks taken");
403407
held_lwlocks[num_held_lwlocks++]=lockid;
404408
}
405409

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp