|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.139 2004/08/29 05:06:48 momjian Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.140 2004/09/12 18:30:50 tgl Exp $ |
12 | 12 | *
|
13 | 13 | * NOTES
|
14 | 14 | * Outside modules can create a lock table and acquire/release
|
@@ -602,7 +602,23 @@ LockAcquire(LOCKMETHODID lockmethodid, LOCKTAG *locktag,
|
602 | 602 | HASH_ENTER, &found);
|
603 | 603 | if (!proclock)
|
604 | 604 | {
|
| 605 | + /* Ooops, not enough shmem for the proclock */ |
| 606 | + if (lock->nRequested == 0) |
| 607 | + { |
| 608 | + /* |
| 609 | + * There are no other requestors of this lock, so garbage-collect |
| 610 | + * the lock object. We *must* do this to avoid a permanent leak |
| 611 | + * of shared memory, because there won't be anything to cause |
| 612 | + * anyone to release the lock object later. |
| 613 | + */ |
| 614 | + Assert(SHMQueueEmpty(&(lock->procLocks))); |
| 615 | + lock = (LOCK *) hash_search(LockMethodLockHash[lockmethodid], |
| 616 | + (void *) &(lock->tag), |
| 617 | + HASH_REMOVE, NULL); |
| 618 | + } |
605 | 619 | LWLockRelease(masterLock);
|
| 620 | + if (!lock) /* hash remove failed? */ |
| 621 | + elog(WARNING, "lock table corrupted"); |
606 | 622 | ereport(ERROR,
|
607 | 623 | (errcode(ERRCODE_OUT_OF_MEMORY),
|
608 | 624 | errmsg("out of shared memory"),
|
@@ -1528,7 +1544,7 @@ LockReleaseAll(LOCKMETHODID lockmethodid, bool allxids)
|
1528 | 1544 | if (!lock)
|
1529 | 1545 | {
|
1530 | 1546 | LWLockRelease(masterLock);
|
1531 |
| - elog(WARNING, "cannot remove lock from HTAB"); |
| 1547 | + elog(WARNING, "lock table corrupted"); |
1532 | 1548 | return FALSE;
|
1533 | 1549 | }
|
1534 | 1550 | }
|
|
0 commit comments