Re: pgsql: Fix race condition in snapshot caching when 2PC is used.

2020-08-19 Thread Andres Freund
Hi, On 2020-08-18 23:31:04 -0400, Tom Lane wrote: > David Rowley writes: > >> On 2020-08-18 19:55:50 -0400, Tom Lane wrote: > >>> On Wed, 19 Aug 2020 at 12:37, Andres Freund wrote: > I'm inclined to just make ClearTransaction take an exclusive lock - the > rest of the 2PC operations ar

Re: pgsql: Fix race condition in snapshot caching when 2PC is used.

2020-08-18 Thread Tom Lane
David Rowley writes: >> On 2020-08-18 19:55:50 -0400, Tom Lane wrote: >>> On Wed, 19 Aug 2020 at 12:37, Andres Freund wrote: I'm inclined to just make ClearTransaction take an exclusive lock - the rest of the 2PC operations are so heavyweight that I can't imagine making a differenc

Re: pgsql: Fix race condition in snapshot caching when 2PC is used.

2020-08-18 Thread David Rowley
On Wed, 19 Aug 2020 at 12:37, Andres Freund wrote: > > Hi, > > On 2020-08-18 19:55:50 -0400, Tom Lane wrote: > > > I'm inclined to just make ClearTransaction take an exclusive lock - the > > > rest of the 2PC operations are so heavyweight that I can't imagine > > > making a difference. When I tes

Re: pgsql: Fix race condition in snapshot caching when 2PC is used.

2020-08-18 Thread Andres Freund
Hi, On 2020-08-18 19:55:50 -0400, Tom Lane wrote: > > I'm inclined to just make ClearTransaction take an exclusive lock - the > > rest of the 2PC operations are so heavyweight that I can't imagine > > making a difference. When I tested the locking changes in > > ProcArrayAdd()/Remove() the more h

Re: pgsql: Fix race condition in snapshot caching when 2PC is used.

2020-08-18 Thread Tom Lane
Andres Freund writes: > On 2020-08-18 19:43:24 -0400, Tom Lane wrote: >> Uh, is it really okay to modify that variable with only shared >> ProcArrayLock? > Uh, you're right. I assume it'll fix the buildfarm visible issue > regardless, but we surely don't want to rely on that. Yeah, having a fai

Re: pgsql: Fix race condition in snapshot caching when 2PC is used.

2020-08-18 Thread Andres Freund
Hi, On 2020-08-18 19:43:24 -0400, Tom Lane wrote: > Andres Freund writes: > > Fix race condition in snapshot caching when 2PC is used. > > Uh, is it really okay to modify that variable with only shared > ProcArrayLock? Uh, you're right. I assume it'll fix the buildfarm visible issue regardless

Re: pgsql: Fix race condition in snapshot caching when 2PC is used.

2020-08-18 Thread Tom Lane
Andres Freund writes: > Fix race condition in snapshot caching when 2PC is used. Uh, is it really okay to modify that variable with only shared ProcArrayLock? regards, tom lane

pgsql: Fix race condition in snapshot caching when 2PC is used.

2020-08-18 Thread Andres Freund
Fix race condition in snapshot caching when 2PC is used. When preparing a transaction xactCompletionCount needs to be incremented, even though the transaction has not committed yet. Otherwise the snapshot used within the transaction otherwise can get reused outside of the prepared transaction. As