Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eyy7q-0007qU-BC for pgsql-general@arkaria.postgresql.org; Thu, 22 Mar 2018 11:11:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eyy7p-0004TI-4s for pgsql-general@arkaria.postgresql.org; Thu, 22 Mar 2018 11:11:17 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eyy7o-0004T8-Mv for pgsql-general@lists.postgresql.org; Thu, 22 Mar 2018 11:11:16 +0000 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eyy7k-0001ZE-H1 for pgsql-general@postgresql.org; Thu, 22 Mar 2018 11:11:15 +0000 Received: by mail-pl0-x244.google.com with SMTP id u11-v6so5068285plq.1 for ; Thu, 22 Mar 2018 04:11:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=lpIozVSQO5PxS3dBpipAr3H/E9dUE5NtCu9btdf+h9Q=; b=KwxsZqeFKIQqwe0CH9spSZy5EB1XBcFUHcudWnmTtrkcd1rue/9lJIWVcH83otEkXx t4LvHWtG71ALZo98LddkI+4helKPbZdonF522DYZxlRb5xCjNPtJrxD/r2IIWmV5Ya8w Udyf9TxERE4MJh2jwvUBJzFqbOVCaHD51lrOZT1S61BUtRgTq73M26kaVuLScA8zjWvC IaxWDIhhbtBTy5OQaw9U3xi3WGJ8bO+RfGbYsHE0W5sg84IypxBBQ+Yrnh3Y/eEra/hB vbjIkqdWU3T68RTkCJMznmi7ooF7gyksehXG7PteMiPXp1SNbYKyH/U9MQkHzti6l/Ob WJkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=lpIozVSQO5PxS3dBpipAr3H/E9dUE5NtCu9btdf+h9Q=; b=Iv8TLx/Z63pCJaotJZEvI0g81D4hMLFeOhzDNcV6SCEhXWKaNI3cIGaanJcoyNpYsF RBAtDK62oEaflJwbS/GIw933li6oin9gDSXO38E5U4xA3q5fM/fYPR5/uVLBSzx31BIA 8xl9EFhNr0ZGfiAmjhSFCMIE+E/oQP8h/cy+/NEfnaN7cz0zvCzdSDZ5lry0CsWV8C/n lDz5biq+WkRRK9olcMPmhyalgq8+z6yfBQgYVPtwY6ImygB7Teqypi4Gp5wZ/0yJ/PF2 t2APmmQrjKXwKBGswIbSSzIchdIHNWjecvhpI3A03H6pd9GwTcbV2NSXkkSRBzQklMrS KENA== X-Gm-Message-State: AElRT7E9xeCfn0c5plbVlw2dMrsSQdJZdncnSo5ebKqWNDYupCO4V0/1 wA9ojKovihxVINifaV20g/E= X-Google-Smtp-Source: AG47ELsUJnrVQhEvv1nnGMVEGgVfY5zOZRczajVT8Yf2lLEuM2RnPeWafUA8zDPtVwb6POwT5BGhrA== X-Received: by 2002:a17:902:b20b:: with SMTP id t11-v6mr4423772plr.371.1521717071194; Thu, 22 Mar 2018 04:11:11 -0700 (PDT) Received: from roblaptop (d49-188-3-97.sun1.vic.optusnet.com.au. [49.188.3.97]) by smtp.gmail.com with ESMTPSA id e125sm11345256pgc.76.2018.03.22.04.11.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Mar 2018 04:11:10 -0700 (PDT) Message-ID: <1521717063.3546.3.camel@gmail.com> Subject: Re: Foreign Key locking / deadlock issue.... v2 From: rob stone To: HORDER Phil , Adrian Klaver Cc: pgsql-general Date: Thu, 22 Mar 2018 22:11:03 +1100 In-Reply-To: <2d10a11d4b624988a21133d218a95c19@XEXWIN0001.one-02-priv.grp> References: <2d10a11d4b624988a21133d218a95c19@XEXWIN0001.one-02-priv.grp> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.2-1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello Phil, On Wed, 2018-03-21 at 15:26 +0000, HORDER Phil wrote: > OK, > Let's try again, with a full script, and including the bit that makes > the difference… > > Hi, > I’m trying to understand why I’m getting a deadlock issue, and how to > work around it. > > At base, I think the problem is: > 1. Updates to a parent table are creating row level write > locks. > 2. updates to a child table set the foreign key value to > the parent table, which are then blocked – because there is Row Level > Security on the parent table. > > > > -- The setup > ------------ > > drop table if exists ELN; > drop table if exists PL; > > Create table PL > (pl_id integer, > m_number text > ); > > > alter table PL ENABLE row level security; > alter table PL FORCE row level security; > > -- A dummy security policy, that allows everybody access to > everything > drop policy if exists security_policy on PL ; I don't use row level security but after reading the documentation, I'd alter this:- > create policy security_policy on PL TO public using (true); -- (1) to CREATE POLICY security_policy on PL FOR ALL TO PUBLIC USING (true) WITH CHECK (true); and trying again. HTH, Rob