Re: out-of-order XID insertion in KnownAssignedXids

From: Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: out-of-order XID insertion in KnownAssignedXids
Date: 2018-10-08 09:33:20
Message-ID: 6ac20e7b-08a7-eb00-08f7-d332ec1f5605@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 08.10.2018 12:14, Michael Paquier wrote:
> On Mon, Oct 08, 2018 at 12:04:28PM +0300, Konstantin Knizhnik wrote:
>> The simplest way to fix the problem is to ignore duplicates before adding
>> them to KnownAssignedXids.
>> We in any case perform sort i this place...
> I may of course be missing something, but shouldn't we not have
> duplicates in the first place?
The reason of appearing duplicated XIDs in case of 2PC seems to be clear.
It may be possible to eliminate it by clearing XID of MyPgxact for
prepared transaction.
But there are two problems with it:
1. I am not sure that it will not break something
2. There is obvious race condition between adding GXACT to ProcArrayAdd
and invalidating XID of current transaction.
If it is cleared before calling ProcArrayAdd, then there will be some
moment when XID is not present in procarray.
If it is done after calling ProcArrayAdd, then still it is possible to
see duplicated XID in procarray.

From my point of view it is easier and less invasive to exclude
duplicates while replaying RUNNING_XIDS record.

--
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2018-10-08 09:49:46 exclude tmp_check and tmp_install from pgindent
Previous Message Peter Eisentraut 2018-10-08 09:32:23 Re: pgsql: Fix event triggers for partitioned tables