Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql General > deadlock debug ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 15635 of 17437
Post > Topic >>

deadlock debug methodology question

by antiochus.usa@[EMAIL PROTECTED] ("antiochus antiochus") May 22, 2008 at 11:34 AM

------=_Part_1008_7645788.1211470499821
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi All,

I have a deadlock situation, two transactions waiting on each other to
complete. Based on the details below, would anyone have recommendations
for
me, please?

Regards,

A.


I am using:
rpm -qa|grep postgres
compat-postgresql-libs-4-2PGDG.rhel5_x86_64
postgresql-server-8.2.6-1PGDG.rhel5
postgresql-8.2.6-1PGDG.rhel5
postgresql-devel-8.2.6-1PGDG.rhel5
postgresql-libs-8.2.6-1PGDG.rhel5

I set 'deadlock_timeout = 1h' in order to have time to inspect pg_locks.

The locks are:

db0=# select * from pg_locks where not granted;
   locktype    | database | relation | page | tuple | transactionid |
classid | objid | objsubid | transaction | pid  |   mode    | granted
---------------+----------+----------+------+-------+---------------+---------+-------+----------+-------------+------+-----------+---------
 transactionid |          |          |      |       |          1407
|         |       |          |        1404 | 8303 | ShareLock | f
 transactionid |          |          |      |       |          1404
|         |       |          |        1407 | 8277 | ShareLock | f
(2 rows)

Each transaction seems to be waiting on a row-level lock the other has
acquired. The tuples are:

db0=# select * from pg_locks where locktype='tuple';
 locktype | database | relation | page | tuple | transactionid | classid |
objid | objsubid | transaction | pid  |     mode      | granted
----------+----------+----------+------+-------+---------------+---------+-------+----------+-------------+------+---------------+---------
 tuple    |    16384 |    16576 |   38 |     6 |               |
|       |          |        1407 | 8277 | ExclusiveLock | t
 tuple    |    16384 |    16576 |   38 |     5 |               |
|       |          |        1404 | 8303 | ShareLock     | t
(2 rows)

The corresponding rows are:

db0=# select id from tt where ctid = '(38,6)';
 id
-----
 600
(1 row)
db0=# select id from tt where ctid = '(38,5)';
 id
-----
 611
(1 row)

Note that the id column is defined as 'id serial primary key'.

The two queries in effect in each transaction are found using:

select current_query from pg_stat_activity where procpid = 8303;
select current_query from pg_stat_activity where procpid = 8277;

Careful inspection of these (unfortunately complex) queries seems to
indicate row-level locks are acquired in consistent order, assuming that
any
command of the type

update tt where ....

will always lock rows in a consistent order (can someone confirm that it
is
necessarily the case).

Therefore, it is not clear to me how this deadlock situation arises.

Does anyone have a recommendation?

------=_Part_1008_7645788.1211470499821
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

<div>Hi All,<br>&nbsp;<br>I have a deadlock situation, two transactions
waiting on each other to complete. Based on the details below, would
anyone have recommendations for me, please?</div>
<div>&nbsp;<br>Regards,<br>&nbsp;<br>A.<br>&nbsp;<br>&nbsp;<br>I am
using:<br>rpm -qa|grep
postgres<br>compat-postgresql-libs-4-2PGDG.rhel5_x86_64<br>postgresql-server-8.2.6-1PGDG.rhel5<br>postgresql-8.2.6-1PGDG.rhel5<br>postgresql-devel-8.2.6-1PGDG.rhel5<br>
postgresql-libs-8.2.6-1PGDG.rhel5<br>&nbsp;<br>I set &#39;deadlock_timeout
= 1h&#39; in order to have time to inspect pg_locks.</div>
<p>The locks are:<br>&nbsp;<br>db0=# select * from pg_locks where not
granted;<br>&nbsp;&nbsp; locktype&nbsp;&nbsp;&nbsp; | database | relation
| page | tuple | transactionid | classid | objid | objsubid | transaction
| pid&nbsp; |&nbsp;&nbsp; mode&nbsp;&nbsp;&nbsp; | granted<br>
---------------+----------+----------+------+-------+---------------+---------+-------+----------+-------------+------+-----------+---------<br>&nbsp;transactionid
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1407
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1404 | 8303 | ShareLock |
f<br>
&nbsp;transactionid
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1404
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1407 | 8277 | ShareLock |
f<br>(2 rows)<br>&nbsp;<br>Each transaction seems to be waiting on a
row-level lock the other has acquired. The tuples are:<br>
&nbsp;<br>db0=# select * from pg_locks where
locktype=&#39;tuple&#39;;<br>&nbsp;locktype | database | relation | page |
tuple | transactionid | classid | objid | objsubid | transaction |
pid&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; mode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |
granted<br>----------+----------+----------+------+-------+---------------+---------+-------+----------+-------------+------+---------------+---------<br>
&nbsp;tuple&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp; 16384
|&nbsp;&nbsp;&nbsp; 16576 |&nbsp;&nbsp; 38 |&nbsp;&nbsp;&nbsp;&nbsp; 6
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1407 | 8277 | ExclusiveLock |
t<br>&nbsp;tuple&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp; 16384
|&nbsp;&nbsp;&nbsp; 16576 |&nbsp;&nbsp; 38 |&nbsp;&nbsp;&nbsp;&nbsp; 5
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1404 | 8303 |
ShareLock&nbsp;&nbsp;&nbsp;&nbsp; | t<br>
(2 rows)</p>
<p>The corresponding rows are:<br>&nbsp;<br>db0=# select id from tt where
ctid = &#39;(38,6)&#39;;<br>&nbsp;id&nbsp; <br>-----<br>&nbsp;600 <br>(1
row)<br>db0=# select id from tt where ctid =
&#39;(38,5)&#39;;<br>&nbsp;id&nbsp; <br>-----<br>&nbsp;611<br>(1 row)</p>

<p>Note that the id column is defined as &#39;id serial primary
key&#39;.<br>&nbsp;<br>The two queries in effect in each transaction are
found using:<br>&nbsp;<br>select current_query from pg_stat_activity where
procpid = 8303;<br>
select current_query from pg_stat_activity where procpid =
8277;<br>&nbsp;<br>Careful inspection of these (unfortunately complex)
queries seems to indicate row-level locks are acquired in consistent
order, assuming that any command of the type<br>
&nbsp;<br>update tt where ....<br>&nbsp;<br>will always lock rows in a
consistent order (can someone confirm that it is necessarily the
case).</p>
<p>Therefore, it is not clear to me how this deadlock situation
arises.</p>
<p>Does anyone have a recommendation?<br>&nbsp;</p>

------=_Part_1008_7645788.1211470499821--
 




 5 Posts in Topic:
deadlock debug methodology question
antiochus.usa@[EMAIL PROT  2008-05-22 11:34:59 
Re: deadlock debug methodology question
wmoran@[EMAIL PROTECTED]   2008-05-22 14:57:37 
Re: deadlock debug methodology question
antiochus.usa@[EMAIL PROT  2008-05-22 15:15:58 
Re: deadlock debug methodology question
wmoran@[EMAIL PROTECTED]   2008-05-22 16:20:57 
Re: deadlock debug methodology question
antiochus.usa@[EMAIL PROT  2008-05-22 17:13:24 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 12:51:50 CST 2008.