deadlock in single-row select-for-update + update scenario? How could it happen?

From: hubert depesz lubaczewski <depesz(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: deadlock in single-row select-for-update + update scenario? How could it happen?
Date: 2014-08-22 16:29:00
Message-ID: CAKrjmhdN+GhAjNwqfHsOtGp+7YN27zR79m99RcAJMNazt5NJrA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have developer with pg 9.3.5, which is reporing something really strange.

He runs importer, which does, in single transaction:

begin;
select * from table where pkey = <value> limit 1 for update;
update table set ... where pkey = <the same_value>;
commit;

and two backends running the same transaction deadlock.

I checked for duplicated rows with the same pkey value - none are there.
And frankly - I'm out of ideas.

What could be wrong in such case?

Detailed logs, with just some obfuscation:
https://depesz.privatepaste.com/0594a93459

depesz

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2014-08-22 16:45:46 Re: deadlock in single-row select-for-update + update scenario? How could it happen?
Previous Message Joseph Kregloh 2014-08-22 15:38:36 Restart replicated slave procedure