diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-07-16 21:09:50 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-07-16 21:09:50 +0000 |
commit | 82b3684672d1de55d244f9908d1bb327ff6acd1d (patch) | |
tree | 621ed171a0e800dbcc1086d21fae28f53f81197e /src/backend/storage/lmgr/proc.c | |
parent | e9e97500c908fc39c37baecc3be9b02c7a5c7cd5 (diff) | |
download | postgresql-82b3684672d1de55d244f9908d1bb327ff6acd1d.tar.gz postgresql-82b3684672d1de55d244f9908d1bb327ff6acd1d.zip |
Add comments spelling out why it's a good idea to release multiple
partition locks in reverse order.
Diffstat (limited to 'src/backend/storage/lmgr/proc.c')
-rw-r--r-- | src/backend/storage/lmgr/proc.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 367c0e6cf81..6e7efe6d6c9 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.190 2007/06/19 22:01:15 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.191 2007/07/16 21:09:50 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1168,9 +1168,11 @@ CheckDeadLock(void) } /* - * Release locks acquired at head of routine. Order is not critical, so - * do it back-to-front to avoid waking another CheckDeadLock instance - * before it can get all the locks. + * And release locks. We do this in reverse order for two reasons: + * (1) Anyone else who needs more than one of the locks will be trying + * to lock them in increasing order; we don't want to release the other + * process until it can get all the locks it needs. + * (2) This avoids O(N^2) behavior inside LWLockRelease. */ check_done: for (i = NUM_LOCK_PARTITIONS; --i >= 0;) |