From: | Chris Angelico <rosuav(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Order of granting with many waiting on one lock |
Date: | 2013-02-11 06:56:36 |
Message-ID: | CAPTjJmqsAEm=jpv2KJ=Uub=ZisXEARCMzDR47qedzks7RRjdJA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I've poked around a bit with my good friend Google Search and come up
blank, and I'm fairly sure this is something that shouldn't be relied
upon, but it's a point of curiosity.
Suppose I have twenty processes that all request the same lock. (I'm
working with pg_advisory_xact_lock, but any exclusive lock should do.)
One of them will obtain it, the others will block. The winner then
holds the lock for a second or so, then commits (releasing the lock),
then goes back and requests it again. Rinse and repeat. Yes, I know
this sounds ridiculous, but it's a simplified version of the
worst-case scenario in one of our systems.
The question is: How is it decided which process will get the lock
when the previous one commits? Is there any sort of guarantee that all
the processes will eventually get a turn, or could two processes
handball the lock to each other and play keepings-off against the
other eighteen?
Chris Angelico
From | Date | Subject | |
---|---|---|---|
Next Message | Pavan Deolasee | 2013-02-11 07:12:57 | Re: Order of granting with many waiting on one lock |
Previous Message | John R Pierce | 2013-02-11 06:47:24 | Re: REINDEX deadlock - Postgresql -9.1 |