pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Sackville-West <awest@janrain.com>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: pgsql-bugs@postgresql.org
Cc: Paulo Tanimoto <paulo@janrain.com>
Subject: Re: regression, deadlock in high frequency single-row UPDATE
Date: Mon, 8 Dec 2014 15:55:52 -0800
Message-ID: <20141208235552.GZ6930@andrew-ThinkPad-X230> (raw)
In-Reply-To: <20140804163027.GI5475@eldon.alvh.no-ip.org>
References: <20140731233051.GN17765@andrew-ThinkPad-X230>
	<20140801005950.GF5475@eldon.alvh.no-ip.org>
	<20140804161205.GA30380@andrew-ThinkPad-X230>
	<20140804163027.GI5475@eldon.alvh.no-ip.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Some months later (stupid business priorities...) we have something to
report on this. We have been able to produce a minimal schema to
demonstrate the problem, and successfully induced the deadlock using
pgbench (thanks to Paulo Tanimoto, cc-ed here).

Please see:

https://gist.github.com/andrewsw-janrain/40d1687db013b1e7c3b3

for detailed instructions on how to trigger the deadlock.

I would be thrilled to learn that we've done something wrong here,
otherwise I think this represents a regression introduced in 9.3.

A

On Mon, Aug 04, 2014 at 12:30:27PM -0400, Alvaro Herrera wrote:
> Andrew Sackville-West wrote:
>
> > > I don't think you have provided everything: for instance I see that your
> > > log has INSERTs into table access_tokens, which has a foreign key
> > > relationship to/from some other table you showed.
> >
> > Ah you're correct, I'll attach the description of that table. But,
> > really, that is all that's going on in the database.
>
> See, access_tokens has a foreign key to access_grants.  So when the
> insert to access_tokens happens, the process also acquires a lock on a
> tuple on access_grants, which should not conflict with the UPDATE; but
> apparently it is blocking in some cases, for unknown reasons.  But note
> that one of the original tables had a large number of foreign keys to
> other tables; are those necessary to reproduce the problem?  I mean, if
> you just copy those three tables to an otherwise empty database and then
> run the hanging application, do you see a problem?  If not, does adding
> all those other tables cause the problem to show up?
>
> Note that the set of columns covered by unique indexes is very
> important.  Your \d does not have an unique index on the updated column
> AFAICS; but if it did have one, things would be completely different
> (because then the insert would definitely conflict with the update).
>
> It would help a lot of you posted the table definitions as pg_dump -t
> output rather than \d, because it's much easier for me to reproduce the
> setup, rather than cutting and pasting the \d output into CREATE TABLE
> commands.
>
> --
> Álvaro Herrera                http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Training & Services
>
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs

--


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (34+ messages)  latest in thread

Message-ID: <20141208235552.GZ6930@andrew-ThinkPad-X230>
Permalink:  ../20141208235552.GZ6930@andrew-ThinkPad-X230/
Also on:    postgresql.org/message-id/20141208235552.GZ6930@andrew-ThinkPad-X230

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: awest@janrain.com, alvherre@2ndquadrant.com, paulo@janrain.com
  Subject: Re: regression, deadlock in high frequency single-row UPDATE
  In-Reply-To: <20141208235552.GZ6930@andrew-ThinkPad-X230>
  References: <20140731233051.GN17765@andrew-ThinkPad-X230> <20140801005950.GF5475@eldon.alvh.no-ip.org> <20140804161205.GA30380@andrew-ThinkPad-X230> <20140804163027.GI5475@eldon.alvh.no-ip.org> <20141208235552.GZ6930@andrew-ThinkPad-X230>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox