From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: ruralhunter@gmail.com
Cc: gsievers19@comcast.net
Cc: berto.d.sera@gmail.com
Cc: pgsql-admin@postgresql.org
Subject: Re: lock problem
Date: Wed, 21 Dec 2011 21:26:26 -0600
Message-ID: <4EF24F020200002500043FA3@gw.wicourts.gov> (raw)
Rural Hunter wrote:
> Kevin Grittner wrote:
>> Rural Hunter wrote:
>>
>>> I still have this question:
>>> same statement A,B,C,D update same row. The start order is
>>> A->B->C-D. From what I've gotten, B/C/D got the lock before A.
>>> Why did that happen?
>>
>> Did you do anything to prevent it from happening? If not, the OS
>> scheduler is going to give time to one process or another in a
>> fairly unpredictable way.
>
> hmm....no I didn't do anything. is the lock priority decided by OS
> not the DB?
What the heck is "lock priority"? I'm not familiar with that term.
> I'm confused here. B/C/D started several mins later than A here
> while the update statement takes no more than 1 second. of coz
> there are hundreds of connections trying to acquire the lock during
> that time.
Well, that sounds like your problem right there. If you have
hundreds of connections, among a great many other problems,
competition for locks can leave any one connection shut out for quite
a long time. If you have hundreds of connections, you will have this
and other problems indefinitely. Right now, look into setting up
pgpool or some other connection pooler to accept your hundreds of
connections, and funnel them into a number of connections somewhere
around double the number of cores on your server. Use transaction-
based pooling, so that when you have more transactions than the
server can efficiently handle, the extras will queue. This will
improve both your overall throughput and your latency (response
time).
Many people naively think that even when the server is saturated,
throwing another transaction at it right away will get a response for
it sooner. That is dead wrong.
-Kevin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: Kevin.Grittner@wicourts.gov, ruralhunter@gmail.com, gsievers19@comcast.net, berto.d.sera@gmail.com
Subject: Re: lock problem
In-Reply-To: <4EF24F020200002500043FA3@gw.wicourts.gov>
References: <4EF24F020200002500043FA3@gw.wicourts.gov>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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