Re: regression, deadlock in high frequency single-row UPDATE

Mark Kirkwood <mark.kirkwood@catalyst.net.nz>

From: Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Andrew Sackville-West <awest@janrain.com>, pgsql-bugs@postgresql.org, Paulo Tanimoto <paulo@janrain.com>
Date: 2014-12-12T08:36:04Z
Lists: pgsql-bugs
On 12/12/14 06:22, Alvaro Herrera wrote:

> Before this can be committed I need an isolationtester spec file that
> reproduces the problem.  Now that I understand why it happens it should
> be easy to produce: just have a transaction that does BEGIN, then the
> insert, and keeps the transaction open; enough other sessions run the
> UPDATE until the problem pops up.  (Also, comments on
> Would_MultiXactIdWait_Block need work.)
>


FWIW - I was having a look at the isolationtester spec. Playing with the 
pgbench setup to see the minimal number of session I needed to provoke 
the deadlock  (unpatched 9.5 code) seemed to converge to about 4. I 
managed to still see 1 deadlock with each session only doing 1 
transaction - i.e:

$ pgbench -c 4 -C  -n -t 1 -f query.sql deadlock

...which resulted in 1 deadlock. So we may be able to get a reasonable 
test case that shows this up! I'll take a look at setting up a test case 
later - but don't let that stop you doing it 1st :-)

Cheers

Mark



Commits

  1. Add isolationtester spec for old heapam.c bug

  2. Improve concurrency of foreign key locking