Re: Truncate in synchronous logical replication failed
Japin Li <japinli@hotmail.com>
From: Japin Li <japinli@hotmail.com>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: "osumi.takamichi@fujitsu.com" <osumi.takamichi@fujitsu.com>, Ajin
Cherian <itsajin@gmail.com>, Petr Jelinek <petr.jelinek@enterprisedb.com>,
Peter Eisentraut <peter.eisentraut@2ndquadrant.com>,
"tanghy.fnst@fujitsu.com" <tanghy.fnst@fujitsu.com>,
"pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2021-04-26T07:07:44Z
Lists: pgsql-hackers
On Mon, 26 Apr 2021 at 12:49, Amit Kapila <amit.kapila16@gmail.com> wrote: > On Fri, Apr 23, 2021 at 7:18 PM osumi.takamichi@fujitsu.com > <osumi.takamichi@fujitsu.com> wrote: >> > > The latest patch looks good to me. I have made a minor modification > and added a commit message in the attached. I would like to once again > ask whether anybody else thinks we should backpatch this? Just a > summary for anybody not following this thread: > > This patch fixes the Logical Replication of Truncate in synchronous > commit mode. The Truncate operation acquires an exclusive lock on the > target relation and indexes and waits for logical replication of the > operation to finish at commit. Now because we are acquiring the shared > lock on the target index to get index attributes in pgoutput while > sending the changes for the Truncate operation, it leads to a > deadlock. > > Actually, we don't need to acquire a lock on the target index as we > build the cache entry using a historic snapshot and all the later > changes are absorbed while decoding WAL. So, we wrote a special > purpose function for logical replication to get a bitmap of replica > identity attribute numbers where we get that information without > locking the target index. > > We are planning not to backpatch this as there doesn't seem to be any > field complaint about this issue since it was introduced in commit > 5dfd1e5a in v11. +1 for apply only on HEAD. -- Regrads, Japin Li. ChengDu WenWu Information Technology Co.,Ltd.
Commits
-
Fix Logical Replication of Truncate in synchronous commit mode.
- e7eea52b2d61 14.0 landed
-
Logical decoding of TRUNCATE
- 5dfd1e5a6696 11.0 cited