Re: BUG #18498: Locking a table from a trigger (with using two sessions) causes a deadlock: the bug or the feature? - Mailing list pgsql-bugs

From David Rowley
Subject Re: BUG #18498: Locking a table from a trigger (with using two sessions) causes a deadlock: the bug or the feature?
Date
Msg-id CAApHDvpXSQ5-=G-bCTYCVNr6EFwdLHJt5ydrN8X14SJds0VzYA@mail.gmail.com
Whole thread Raw
In response to Re: BUG #18498: Locking a table from a trigger (with using two sessions) causes a deadlock: the bug or the feature?  (David Rowley <dgrowleyml@gmail.com>)
Responses Re: BUG #18498: Locking a table from a trigger (with using two sessions) causes a deadlock: the bug or the feature?
List pgsql-bugs
On Fri, 7 Jun 2024 at 20:58, David Rowley <dgrowleyml@gmail.com> wrote:
> s1: create table t ();
> s1: begin;
> s2: begin;
> s1: lock table t in access share mode;
> s2: lock table t in access share mode;
> s1: lock table t in access exclusive mode;
> s2: lock table t in access exclusive mode; -- deadlock
>
> Isn't this more or less the same as what's going on in your scenario?

I didn't explain why this needs to happen...  s1 can't get the AEL on
"t" because it's blocked by s2's share lock. Subsequently, s2 then
must wait on s1's AEL request and that creates a deadlock cycle that
needs to be broken.

David



pgsql-bugs by date:

Previous
From: David Rowley
Date:
Subject: Re: BUG #18498: Locking a table from a trigger (with using two sessions) causes a deadlock: the bug or the feature?
Next
From: Etsuro Fujita
Date:
Subject: Re: BUG #18467: postgres_fdw (deparser) ignores LimitOption