pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedConcurrency
5+ messages / 3 participants
[nested] [flat]
* Concurrency
@ 2005-05-09 17:21 Kris Kiger <kris@musicrebellion.com>
2005-05-09 18:58 ` Re: Concurrency Simon Riggs <simon@2ndquadrant.com>
0 siblings, 1 reply; 5+ messages in thread
From: Kris Kiger @ 2005-05-09 17:21 UTC (permalink / raw)
To: pgsql-admin
Quick question. I lock a table, call it table X, and then issue two
updates on that table. The two updates are left waiting. I then unlock
the table. The two updates go through. My question is, is there a
predictable way to determine which query will be executed first? Thanks
in advance
Kris
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Concurrency
2005-05-09 17:21 Concurrency Kris Kiger <kris@musicrebellion.com>
@ 2005-05-09 18:58 ` Simon Riggs <simon@2ndquadrant.com>
2005-05-09 19:18 ` Re: Concurrency Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 5+ messages in thread
From: Simon Riggs @ 2005-05-09 18:58 UTC (permalink / raw)
To: Kris Kiger <kris@musicrebellion.com>; +Cc: pgsql-admin
On Mon, 2005-05-09 at 12:21 -0500, Kris Kiger wrote:
> Quick question. I lock a table, call it table X, and then issue two
> updates on that table. The two updates are left waiting. I then unlock
> the table. The two updates go through. My question is, is there a
> predictable way to determine which query will be executed first? Thanks
> in advance
The lock queue is served in FIFO sequence. It is predictable, but if you
don't know which order they were submitted in it might be hard to
determine what that predictable order is, if they were submitted almost
at the same time.
...but you shouldn't use locking as a queuing mechanism.
Best Regards, Simon Riggs
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Concurrency
2005-05-09 17:21 Concurrency Kris Kiger <kris@musicrebellion.com>
2005-05-09 18:58 ` Re: Concurrency Simon Riggs <simon@2ndquadrant.com>
@ 2005-05-09 19:18 ` Tom Lane <tgl@sss.pgh.pa.us>
2005-05-09 21:38 ` Re: Concurrency Simon Riggs <simon@2ndquadrant.com>
0 siblings, 1 reply; 5+ messages in thread
From: Tom Lane @ 2005-05-09 19:18 UTC (permalink / raw)
To: Simon Riggs <simon@2ndquadrant.com>; +Cc: Kris Kiger <kris@musicrebellion.com>; pgsql-admin
Simon Riggs <simon@2ndquadrant.com> writes:
> On Mon, 2005-05-09 at 12:21 -0500, Kris Kiger wrote:
>> Quick question. I lock a table, call it table X, and then issue two
>> updates on that table. The two updates are left waiting. I then unlock
>> the table. The two updates go through. My question is, is there a
>> predictable way to determine which query will be executed first?
> The lock queue is served in FIFO sequence.
... usually. We will promote later arrivals in front of older ones if
the alternative would be a deadlock (eg, the later one already holds
some lock that would block the earlier one).
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Concurrency
2005-05-09 17:21 Concurrency Kris Kiger <kris@musicrebellion.com>
2005-05-09 18:58 ` Re: Concurrency Simon Riggs <simon@2ndquadrant.com>
2005-05-09 19:18 ` Re: Concurrency Tom Lane <tgl@sss.pgh.pa.us>
@ 2005-05-09 21:38 ` Simon Riggs <simon@2ndquadrant.com>
2005-05-09 21:46 ` Re: Concurrency Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 5+ messages in thread
From: Simon Riggs @ 2005-05-09 21:38 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Kris Kiger <kris@musicrebellion.com>; pgsql-admin
On Mon, 2005-05-09 at 15:18 -0400, Tom Lane wrote:
> Simon Riggs <simon@2ndquadrant.com> writes:
> > On Mon, 2005-05-09 at 12:21 -0500, Kris Kiger wrote:
> >> Quick question. I lock a table, call it table X, and then issue two
> >> updates on that table. The two updates are left waiting. I then unlock
> >> the table. The two updates go through. My question is, is there a
> >> predictable way to determine which query will be executed first?
>
> > The lock queue is served in FIFO sequence.
>
> ... usually. We will promote later arrivals in front of older ones if
> the alternative would be a deadlock (eg, the later one already holds
> some lock that would block the earlier one).
Thats part of deadlock detection? I had thought we just blew one away...
Thanks,
Best Regards, Simon Riggs
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Concurrency
2005-05-09 17:21 Concurrency Kris Kiger <kris@musicrebellion.com>
2005-05-09 18:58 ` Re: Concurrency Simon Riggs <simon@2ndquadrant.com>
2005-05-09 19:18 ` Re: Concurrency Tom Lane <tgl@sss.pgh.pa.us>
2005-05-09 21:38 ` Re: Concurrency Simon Riggs <simon@2ndquadrant.com>
@ 2005-05-09 21:46 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 5+ messages in thread
From: Tom Lane @ 2005-05-09 21:46 UTC (permalink / raw)
To: Simon Riggs <simon@2ndquadrant.com>; +Cc: Kris Kiger <kris@musicrebellion.com>; pgsql-admin
Simon Riggs <simon@2ndquadrant.com> writes:
> On Mon, 2005-05-09 at 15:18 -0400, Tom Lane wrote:
>> ... usually. We will promote later arrivals in front of older ones if
>> the alternative would be a deadlock (eg, the later one already holds
>> some lock that would block the earlier one).
> Thats part of deadlock detection? I had thought we just blew one away...
Only after deciding that there's no way to rearrange the lock queues to
eliminate the deadlock.
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2005-05-09 21:46 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-05-09 17:21 Concurrency Kris Kiger <kris@musicrebellion.com>
2005-05-09 18:58 ` Simon Riggs <simon@2ndquadrant.com>
2005-05-09 19:18 ` Tom Lane <tgl@sss.pgh.pa.us>
2005-05-09 21:38 ` Simon Riggs <simon@2ndquadrant.com>
2005-05-09 21:46 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox