aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2013-01-18 11:49:52 -0500
committerRobert Haas <rhaas@postgresql.org>2013-01-18 11:52:28 -0500
commitd8c3896626e9fa48c9ebadc31850d54a791a08e3 (patch)
tree4a5ccff6edddcb7b9d59289dcba8c171245f9f5f /src
parent600250d0ed8848391ceb8fb382c299d085856dbc (diff)
downloadpostgresql-d8c3896626e9fa48c9ebadc31850d54a791a08e3.tar.gz
postgresql-d8c3896626e9fa48c9ebadc31850d54a791a08e3.zip
Unbreak lock conflict detection for Hot Standby.
This got broken in the original fast-path locking patch, because I failed to account for the fact that Hot Standby startup process might take a strong relation lock on a relation in a database to which it is not bound, and confused MyDatabaseId with the database ID of the relation being locked. Report and diagnosis by Andres Freund. Final form of patch by me.
Diffstat (limited to 'src')
-rw-r--r--src/backend/storage/lmgr/lock.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c
index f2cf5c6b8eb..84637fe5815 100644
--- a/src/backend/storage/lmgr/lock.c
+++ b/src/backend/storage/lmgr/lock.c
@@ -2445,8 +2445,8 @@ FastPathTransferRelationLocks(LockMethod lockMethodTable, const LOCKTAG *locktag
LWLockAcquire(proc->backendLock, LW_EXCLUSIVE);
/*
- * If the target backend isn't referencing the same database as we
- * are, then we needn't examine the individual relation IDs at all;
+ * If the target backend isn't referencing the same database as the
+ * lock, then we needn't examine the individual relation IDs at all;
* none of them can be relevant.
*
* proc->databaseId is set at backend startup time and never changes
@@ -2459,7 +2459,7 @@ FastPathTransferRelationLocks(LockMethod lockMethodTable, const LOCKTAG *locktag
* fencing operation since the other backend set proc->databaseId. So
* for now, we test it after acquiring the LWLock just to be safe.
*/
- if (proc->databaseId != MyDatabaseId)
+ if (proc->databaseId != locktag->locktag_field1)
{
LWLockRelease(proc->backendLock);
continue;
@@ -2677,14 +2677,14 @@ GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode)
LWLockAcquire(proc->backendLock, LW_SHARED);
/*
- * If the target backend isn't referencing the same database as we
- * are, then we needn't examine the individual relation IDs at
+ * If the target backend isn't referencing the same database as the
+ * lock, then we needn't examine the individual relation IDs at
* all; none of them can be relevant.
*
* See FastPathTransferLocks() for discussion of why we do this
* test after acquiring the lock.
*/
- if (proc->databaseId != MyDatabaseId)
+ if (proc->databaseId != locktag->locktag_field1)
{
LWLockRelease(proc->backendLock);
continue;