Re: Conflict detection and logging in logical replication
Amit Kapila <amit.kapila16@gmail.com>
From: Amit Kapila <amit.kapila16@gmail.com>
To: shveta malik <shveta.malik@gmail.com>
Cc: "Zhijie Hou (Fujitsu)" <houzj.fnst@fujitsu.com>, "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>,
Nisha Moond <nisha.moond412@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>,
Dilip Kumar <dilipbalaut@gmail.com>, Jan Wieck <jan@wi3ck.info>, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Date: 2024-08-19T06:07:44Z
Lists: pgsql-hackers
On Mon, Aug 19, 2024 at 9:08 AM shveta malik <shveta.malik@gmail.com> wrote: > > On Sun, Aug 18, 2024 at 2:27 PM Zhijie Hou (Fujitsu) > <houzj.fnst@fujitsu.com> wrote: > > > > Attach the V16 patch which addressed the comments we agreed on. > > I will add a doc patch to explain the log format after the 0001 is RFC. > > > > Thank You for addressing comments. Please see this scenario: > > create table tab1(pk int primary key, val1 int unique, val2 int); > > pub: insert into tab1 values(1,1,1); > sub: insert into tab1 values(2,2,3); > pub: update tab1 set val1=2 where pk=1; > > Wrong 'replica identity' column logged? shouldn't it be pk? > > ERROR: conflict detected on relation "public.tab1": conflict=update_exists > DETAIL: Key already exists in unique index "tab1_val1_key", modified > locally in transaction 801 at 2024-08-19 08:50:47.974815+05:30. > Key (val1)=(2); existing local tuple (2, 2, 3); remote tuple (1, 2, > 1); replica identity (val1)=(1). > The docs say that by default replica identity is primary_key [1] (see REPLICA IDENTITY), [2] (see pg_class.relreplident). So, using the same format to display PK seems reasonable. I don't think adding additional code to distinguish these two cases in the LOG message is worth it. We can always change such things later if that is what users and or others prefer. [1] - https://www.postgresql.org/docs/devel/sql-altertable.html [2] - https://www.postgresql.org/docs/devel/catalog-pg-class.html -- With Regards, Amit Kapila.
Commits
-
Rename the conflict types for the origin differ cases.
- 640178c92e3f 18.0 landed
-
Doc: explain the log format of logical replication conflicts.
- edcb71258504 18.0 landed
-
Log the conflicts while applying changes in logical replication.
- 9758174e2e5c 18.0 landed
-
Avoid duplicate table scans for cross-partition updates during logical replication.
- a67da49e1d98 18.0 cited