Re: Xact end leaves CurrentMemoryContext = TopMemoryContext
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2024-06-17T21:43:05Z
Lists: pgsql-hackers
Hi, On 2024-06-17 16:37:05 -0400, Tom Lane wrote: > 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. One issue is that that could lead to hard to find use-after-free issues in currently working code. Right now allocations made "between transactions" live forever, if we just use a different context it won't anymore. Particularly if the reset is only occasional, we'd make it hard to find buggy allocations. I wonder if we ought to set CurrentMemoryContext to NULL in that timeframe, forcing code to explicitly choose what lifetime is needed, rather than just defaulting such code into changed semantics. Greetings, Andres Freund
Commits
-
Split vacuumdb to create vacuuming.c/h
- c4067383cb2c 19 (unreleased) cited
-
Preserve CurrentMemoryContext across notify and sinval interrupts.
- 8565fb6fbb69 12.20 landed
- 5f86cd70d801 13.16 landed
- 54a7b21b3a9d 16.4 landed
- 4df767cf906d 15.8 landed
- 31f8d620b287 17.0 landed
- 1608902fc3a7 14.13 landed
-
Preserve CurrentMemoryContext across Start/CommitTransactionCommand.
- 1afe31f03cd2 18.0 landed