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.
Sorry, I didn't include that part because I was retyping the log output, but it did provide that information about the queries and it was two instances like the one that I linked to above. Basically, it's a function that wraps an INSERT with exception handling so that duplicated records won't cause an error. According to the log, the two queries were executing the actual INSERT when the deadlock happened.