Re: Conflict detection and logging in logical replication

From: Michail Nikolaev <michail(dot)nikolaev(at)gmail(dot)com>
To: "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Jan Wieck <jan(at)wi3ck(dot)info>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Subject: Re: Conflict detection and logging in logical replication
Date: 2024-08-09 11:45:12
Message-ID: CANtu0oiFPkHe0HrbnKKCTXdFKVRfhUF8bwKzR9Y7y3Q7bdQKWQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello, everyone.

There are some comments on this patch related to issue [0].
In short: any DirtySnapshot index scan may fail to find an existing tuple
in the case of a concurrent update.

- FindConflictTuple may return false negative result in the case of
concurrent update because ExecCheckIndexConstraints uses SnapshotDirty.
- As a result, CheckAndReportConflict may fail to report the conflict.
- In apply_handle_update_internal we may get an CT_UPDATE_MISSING instead
of CT_UPDATE_DIFFER
- In apply_handle_update_internal we may get an CT_DELETE_MISSING instead
of CT_DELETE_DIFFER
- In apply_handle_tuple_routing we may get an CT_UPDATE_MISSING instead of
CT_UPDATE_DIFFER

If you're interested, I could create a test to reproduce the issue within
the context of logical replication. Issue [0] itself includes a test case
to replicate the problem.

It also seems possible that a conflict could be resolved by a concurrent
update before the call to CheckAndReportConflict, which means there's no
guarantee that the conflict will be reported correctly.
Should we be concerned about this?

[0]: https://commitfest.postgresql.org/49/5151/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2024-08-09 12:07:48 Re: Historic snapshot doesn't track txns committed in BUILDING_SNAPSHOT state
Previous Message Andreas Karlsson 2024-08-09 11:41:26 Re: Remaining dependency on setlocale()