Re: Deadlock when inserting from multiple processes - Mailing list pgsql-admin

From Keith
Subject Re: Deadlock when inserting from multiple processes
Date
Msg-id CAHw75vuRXb7CMU0AV9B0zvYGLB8WfJ7QYogYLosp8M7LsDasiw@mail.gmail.com
Whole thread Raw
In response to Deadlock when inserting from multiple processes  (Dave Johansen <davejohansen@gmail.com>)
Responses Re: Deadlock when inserting from multiple processes  (Dave Johansen <davejohansen@gmail.com>)
List pgsql-admin


On Wed, Apr 27, 2016 at 3:10 PM, Dave Johansen <davejohansen@gmail.com> wrote:
I'm using Postgres 9.2.15 on CentOS 7.2 with the method described below to support INSERTing from multiple processes:
http://www.postgresql.org/message-id/CAAcYxUf9o3NpiKaHdeShO_iJjm92314eX6ko0JvJidmksutkJg@mail.gmail.com

Last night, one of the processes experienced a dead lock. The error looked like this:
ERROR: deadlock detected
DETAIL: Process 23527 waits for ShareLock on transaction 1537228819; blocked by process 34184
        Process 34184 waits for ShareLock on transaction 1537228441; blocked by process 23527.

Is there anything I can do to help diagnose what the cause of this issue was?

Thanks,
Dave

Look in the postgresql logs. It should give you more info on what queries were running in each session that conflicted with each other. If you didn't have the PID as part of your log_line_prefix, that can make it a bit more challenging to figure out which sessions were which, though. I've found this prefix to be very useful (note there is a space at the end):

"%t [%r] [%p]: [%l-1] user=%u,db=%d,e=%e "

9.2 should give you enough info, but I believe more recent versions are much more verbose with their deadlock output to help with debugging.

pgsql-admin by date:

Previous
From: Dave Johansen
Date:
Subject: Deadlock when inserting from multiple processes
Next
From: Sreekanth Palluru
Date:
Subject: Testing hot standby on same server sharing same tablespace directory