RE: locking [user] catalog tables vs 2pc vs logical rep

From: "osumi(dot)takamichi(at)fujitsu(dot)com" <osumi(dot)takamichi(at)fujitsu(dot)com>
To: 'Peter Smith' <smithpb2250(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Markus Wanner <markus(dot)wanner(at)enterprisedb(dot)com>
Subject: RE: locking [user] catalog tables vs 2pc vs logical rep
Date: 2021-06-03 03:48:20
Message-ID: OSBPR01MB48884B4974654EA06C90D5B9ED3C9@OSBPR01MB4888.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tuesday, June 1, 2021 4:33 PM Peter Smith <smithpb2250(at)gmail(dot)com>
> To: Andres Freund <andres(at)anarazel(dot)de>
> Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>; Amit Kapila
> <amit(dot)kapila16(at)gmail(dot)com>; Markus Wanner
> <markus(dot)wanner(at)enterprisedb(dot)com>
> Subject: Re: locking [user] catalog tables vs 2pc vs logical rep
>
> Hi.
>
> The attached PG docs patch about catalog deadlocks was previously
> implemented in another thread [1], but it seems more relevant to this one.
>
> PSA.
Thank you for providing the patch.
I have updated your patch to include some other viewpoints.

For example, CLUSTER command scenario
that also causes hang of PREPARE in synchronous mode.
We get this deadlock, using the 2PC patch-set.

FYI, the scenario is
(1) create a table with a trigger
(2) create pub and sub in synchronous mode
(3) then, execute CLUSTER pg_trigger USING pg_trigger_oid_index,
and do some operations (e.g. INSERT) on the trigger-attached table and PREPARE

The mechanism of this is
walsender tries to take a lock on pg_trigger if the table has a trigger,
but, pg_trigger is already locked by the CLUSTER command, which leads to the deadlock.
Then, this scenario requires some operations on the table which has trigger
because it invokes the walsender to take the lock described above.

I also included the description about TRUNCATE on user_catalog_table
in the patch. Please have a look at this patch.

Best Regards,
Takamichi Osumi

Attachment Content-Type Size
deadlock_caveats_for_logical_decoding_v02.patch application/octet-stream 4.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2021-06-03 03:51:48 Re: Fixup some appendStringInfo and appendPQExpBuffer calls
Previous Message Michael Paquier 2021-06-03 03:13:22 Documentation missing for PGSSLCRLDIR