Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Xy89y-0007dV-NK for pgsql-bugs@arkaria.postgresql.org; Mon, 08 Dec 2014 23:56:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Xy89x-0002t1-Hv for pgsql-bugs@arkaria.postgresql.org; Mon, 08 Dec 2014 23:56:09 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Xy89v-0002ss-CR for pgsql-bugs@postgresql.org; Mon, 08 Dec 2014 23:56:07 +0000 Received: from mail-pa0-x236.google.com ([2607:f8b0:400e:c03::236]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1Xy89m-0000ek-A6 for pgsql-bugs@postgresql.org; Mon, 08 Dec 2014 23:56:04 +0000 Received: by mail-pa0-f54.google.com with SMTP id fb1so6151481pad.41 for ; Mon, 08 Dec 2014 15:55:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janrain.com; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=jwlg1Y1hxiBkjTn/BniGiwslW+J2bCYZX4G0oZhXot0=; b=T2uxEsVqxVtaQYR6/L2Fi0c438DHuqjt89v3tbzJOgX4oaAzTocxl86hlZCWMdLSZG Ucb6RSvxxePRodOc+WOXVlaKzKxo5DHdJBMhP7D59RPe1pTEPbW+omZ240sO8j4tqoxA HecMOw6b4msqhVRUJGc8fTbm4msBKudTnbSak= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-type :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=jwlg1Y1hxiBkjTn/BniGiwslW+J2bCYZX4G0oZhXot0=; b=NU92NwtLHNsN7rWNxqpdzopkmKET2KUvgtYkRzTbQPm5bJz8Me0wxfghn9SkqkyOGO xxpneYPpdEit5jAjLmbWgKt2kLnBpka6en1jvmsUp6eydjJHjz0xbvNmXqIba0ivN0TM t6hbrxyyYXr10UjThF4Jf1fIAMmoIwzKEU6n7Fbib6x9sC2/QRihxePgKoNVJ9wNrFB8 Nh+E8ogUnRuGQHHeAHSSqT06jR7sDfEdzAemA962e+b3HF17iiFoIKvKuLQJnHOSJZN5 hhydc4NeV0Fh4X0OQc9qhmmNkEbh9DNv1ZHuDI9RAt+nb77bNg5WnUTK4yRI50LG8deO oDEw== X-Gm-Message-State: ALoCoQkiCvCRP4UxQZpIqagGFZrwpKODCWJ/9Hh1sa3iO+EG4Vq64f/FJABuMs7B10TdfD7/Fenk X-Received: by 10.66.138.72 with SMTP id qo8mr121571pab.84.1418082954728; Mon, 08 Dec 2014 15:55:54 -0800 (PST) Received: from andrew-ThinkPad-X230 (173-164-68-213-Oregon.hfc.comcastbusiness.net. [173.164.68.213]) by mx.google.com with ESMTPSA id je4sm37216118pbd.94.2014.12.08.15.55.53 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 08 Dec 2014 15:55:54 -0800 (PST) Date: Mon, 8 Dec 2014 15:55:52 -0800 From: Andrew Sackville-West To: Alvaro Herrera Cc: pgsql-bugs@postgresql.org, Paulo Tanimoto Subject: Re: regression, deadlock in high frequency single-row UPDATE Message-ID: <20141208235552.GZ6930@andrew-ThinkPad-X230> Mail-Followup-To: Alvaro Herrera , pgsql-bugs@postgresql.org, Paulo Tanimoto 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> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20140804163027.GI5475@eldon.alvh.no-ip.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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