pgsql: Add pg_backend_memory_contexts system view.

2020-08-18 Thread Fujii Masao
Add pg_backend_memory_contexts system view. This view displays the usages of all the memory contexts of the server process attached to the current session. This information is useful to investigate the cause of backend-local memory bloat. This information can be also collected by calling MemoryCo

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: snapshot scalability: cache snapshots using a xact completion co

2020-08-18 Thread Andres Freund
On 2020-08-18 13:28:05 -0700, Andres Freund wrote: > Hi, > > On 2020-08-18 01:21:17 -0400, Tom Lane wrote: > > Andres Freund writes: > > > I'd written to Tom that I was planning to revert unless the number of > > > failures were lower than initially indicated. But that actually seems to > > > hav

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

Re: pgsql: snapshot scalability: cache snapshots using a xact completion co

2020-08-18 Thread Andres Freund
Hi, On 2020-08-18 01:21:17 -0400, Tom Lane wrote: > Andres Freund writes: > > I'd written to Tom that I was planning to revert unless the number of > > failures were lower than initially indicated. But that actually seems to > > have come to pass (the failures are quicker to report because they d

pgsql: Avoid non-constant format string argument to fprintf().

2020-08-18 Thread Heikki Linnakangas
Avoid non-constant format string argument to fprintf(). As Tom Lane pointed out, it could defeat the compiler's printf() format string verification. Backpatch to v12, like that patch that introduced it. Discussion: https://www.postgresql.org/message-id/1069283.1597672779%40sss.pgh.pa.us Branch

pgsql: Avoid non-constant format string argument to fprintf().

2020-08-18 Thread Heikki Linnakangas
Avoid non-constant format string argument to fprintf(). As Tom Lane pointed out, it could defeat the compiler's printf() format string verification. Backpatch to v12, like that patch that introduced it. Discussion: https://www.postgresql.org/message-id/1069283.1597672779%40sss.pgh.pa.us Branch

pgsql: Avoid non-constant format string argument to fprintf().

2020-08-18 Thread Heikki Linnakangas
Avoid non-constant format string argument to fprintf(). As Tom Lane pointed out, it could defeat the compiler's printf() format string verification. Backpatch to v12, like that patch that introduced it. Discussion: https://www.postgresql.org/message-id/1069283.1597672779%40sss.pgh.pa.us Branch