Re: deadlocks - sharelocks on transactions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tim McAuley <tech-lists(at)mothy(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: deadlocks - sharelocks on transactions
Date: 2004-01-07 15:42:45
Message-ID: 18860.1073490165@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tim McAuley <tech-lists(at)mothy(dot)net> writes:
> I have a stored procedure that is causing deadlocks when called multiple
> times synchronously. The odd issue is that the deadlock seems to be
> happening on different threads waiting for locks on transactions. What
> exactly is this transaction lock?

> ERROR: deadlock detected
> DETAIL: Process 1740 waits for ShareLock on transaction 1488; blocked
> by process 1716.
> Process 1716 waits for ShareLock on transaction 1490; blocked
> by process 1740.

What you've got here is transactions deadlocked by trying to
update/delete the same rows (unfortunately the lock manager doesn't know
exactly which rows, so the DETAIL isn't too helpful).

Most of the complaints I've seen about this sort of problem are not
really from updates per se, but the SELECT FOR UPDATE locking that
is done for foreign key references. Are you inserting multiple rows
that might reference the same foreign keys?

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Wolff III 2004-01-07 15:46:55 Re: Paypal WAS: PostgreSQL speakers needed for OSCON
Previous Message Bruno Wolff III 2004-01-07 15:19:11 Re: Any way to have CREATEUSER privs without having all privs?