Re: out-of-order XID insertion in KnownAssignedXids - Mailing list pgsql-hackers

From Konstantin Knizhnik
Subject Re: out-of-order XID insertion in KnownAssignedXids
Date
Msg-id 6ac20e7b-08a7-eb00-08f7-d332ec1f5605@postgrespro.ru
Whole thread Raw
In response to Re: out-of-order XID insertion in KnownAssignedXids  (Michael Paquier <michael@paquier.xyz>)
List 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



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Procedure calls are not tracked in pg_stat_user_functions /track_functions
Next
From: Peter Eisentraut
Date:
Subject: exclude tmp_check and tmp_install from pgindent