From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-hackers@lists.postgresql.org
Subject: Xact end leaves CurrentMemoryContext = TopMemoryContext
Date: Mon, 17 Jun 2024 16:37:05 -0400
Message-ID: <3478884.1718656625@sss.pgh.pa.us> (raw)
AtCommit_Memory and friends have done $SUBJECT for at least a couple
of decades, but in the wake of analyzing bug #18512 [1], I'm feeling
like that's a really bad idea. There is too much code running
around the system that assumes that it's fine to leak stuff in
CurrentMemoryContext. If we execute any such thing between
AtCommit_Memory and the next AtStart_Memory, presto: we have a
session-lifespan memory leak. I'm almost feeling that we should
have a policy that CurrentMemoryContext should never point at
TopMemoryContext.
As to what to do about it: I'm imagining that instead of resetting
CurrentMemoryContext to TopMemoryContext, we set it to some special
context that we expect we can reset every so often, like at the start
of the next transaction. The existing TransactionAbortContext is
a very similar thing, and maybe could be repurposed/shared with this
usage.
Thoughts?
regards, tom lane
[1] https://www.postgresql.org/message-id/18512-6e89f654d7da884d%40postgresql.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, pgsql-hackers@lists.postgresql.org
Subject: Re: Xact end leaves CurrentMemoryContext = TopMemoryContext
In-Reply-To: <3478884.1718656625@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox