pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: rob stone <floriparob@gmail.com>
To: HORDER Phil <Phil.Horder@uk.thalesgroup.com>
To: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: Foreign Key locking / deadlock issue.... v2
Date: Thu, 22 Mar 2018 22:11:03 +1100
Message-ID: <1521717063.3546.3.camel@gmail.com> (raw)
In-Reply-To: <2d10a11d4b624988a21133d218a95c19@XEXWIN0001.one-02-priv.grp>
References: <2d10a11d4b624988a21133d218a95c19@XEXWIN0001.one-02-priv.grp>

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





view thread (9+ messages)  latest in thread

Message-ID: <1521717063.3546.3.camel@gmail.com>
Permalink:  ../1521717063.3546.3.camel@gmail.com/
Also on:    postgresql.org/message-id/1521717063.3546.3.camel@gmail.com

 · 

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-general@postgresql.org
  Cc: floriparob@gmail.com, Phil.Horder@uk.thalesgroup.com, adrian.klaver@aklaver.com
  Subject: Re: Foreign Key locking / deadlock issue.... v2
  In-Reply-To: <1521717063.3546.3.camel@gmail.com>
  References: <2d10a11d4b624988a21133d218a95c19@XEXWIN0001.one-02-priv.grp> <1521717063.3546.3.camel@gmail.com>

* 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