From: | Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp> |
---|---|
To: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
Cc: | Dmitry <dsy(dot)075(at)yandex(dot)ru>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Inconsistent update in the MERGE command |
Date: | 2025-08-28 14:10:01 |
Message-ID: | 20250828231001.c8bc9fbcd1f1288002348609@sraoss.co.jp |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, 27 Aug 2025 14:44:55 +0100
Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
> On Sun, 24 Aug 2025 at 18:34, Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp> wrote:
> >
> > I confirmed this issue by executing the following query concurrently
> > in three transactions. (With only two transactions, the issue does not occur.)
>
> Yes, I think 3 transactions are required to reproduce this (2 separate
> concurrent updates).
>
> > I don't completely understand how this race condition occurs,
> > but I believe the bug is due to the misuse of TM_FailureData
> > returned by table_tuple_lock in ExecMergeMatched().
> >
> > Currently, TM_FailureData.ctid is used as a reference to the
> > latest version of oldtuple, but this is not always correct.
> > Instead, the tupleid passed to table_tuple_lock should be used.
> >
> > I've attached a patch to fix this.
>
> Thanks. That makes sense.
>
> I think we also should update the isolation tests to test this.
> Attached is an update to the merge-match-recheck isolation test, doing
> so. As you found, it doesn't always seem to fail with the unpatched
> code (though I didn't look to see why), but with your patch, it always
> passes.
Thank you for your suggestion and the test patch. The test looks good
to me, so I’ve attached an updated patch including it.
Regards,
Yugo Nagata
--
Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>
Attachment | Content-Type | Size |
---|---|---|
v2-0001-Fix-misuse-of-TM_FailureData.ctid-in-ExecMergeMat.patch | text/x-diff | 12.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Sami Imseih | 2025-08-28 15:28:54 | Re: Improve LWLock tranche name visibility across backends |
Previous Message | Daniel Gustafsson | 2025-08-28 13:29:41 | Re: Generate GUC tables from .dat file |