Commit 31f8d62
committed
Preserve CurrentMemoryContext across notify and sinval interrupts.
ProcessIncomingNotify is called from the main processing loop that
normally runs in MessageContext. That outer-loop code assumes that
whatever it allocates will be cleaned up when we're done processing
the current client message --- but if we service a notify interrupt,
then whatever gets allocated before the next switch into
MessageContext will be permanently leaked in TopMemoryContext,
because CommitTransactionCommand sets CurrentMemoryContext to
TopMemoryContext. There are observable leaks associated with
(at least) encoding conversion of incoming queries and parameters
attached to Bind messages.
sinval catchup interrupts have a similar problem. There might be
others, but I've not identified any other clear cases.
To fix, take care to save and restore CurrentMemoryContext across
the Start/CommitTransactionCommand calls in these functions.
Per bug #18512 from wizardbrony. Commit to back branches only;
in HEAD, this was dealt with by the riskier but more thoroughgoing
approach in commit 1afe31f.
Discussion: https://postgr.es/m/3478884.1718656625@sss.pgh.pa.us1 parent 6d2ac55 commit 31f8d62
2 files changed
+17
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2182 | 2182 | | |
2183 | 2183 | | |
2184 | 2184 | | |
| 2185 | + | |
| 2186 | + | |
2185 | 2187 | | |
2186 | 2188 | | |
2187 | 2189 | | |
| |||
2196 | 2198 | | |
2197 | 2199 | | |
2198 | 2200 | | |
2199 | | - | |
| 2201 | + | |
| 2202 | + | |
2200 | 2203 | | |
| 2204 | + | |
| 2205 | + | |
2201 | 2206 | | |
2202 | 2207 | | |
2203 | 2208 | | |
2204 | 2209 | | |
2205 | 2210 | | |
2206 | 2211 | | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
2207 | 2216 | | |
2208 | 2217 | | |
2209 | 2218 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
182 | 183 | | |
183 | 184 | | |
184 | 185 | | |
| 186 | + | |
185 | 187 | | |
186 | 188 | | |
187 | 189 | | |
| |||
195 | 197 | | |
196 | 198 | | |
197 | 199 | | |
| 200 | + | |
| 201 | + | |
198 | 202 | | |
199 | 203 | | |
200 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
201 | 208 | | |
202 | 209 | | |
203 | 210 | | |
0 commit comments