summaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlogstats.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2025-10-09 15:37:42 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2025-10-09 15:37:42 -0400
commit89d57c1fb35522590ec1f70b123c853cf5a9acb2 (patch)
tree6ac439f1b203478dce0f2a1a5966c44602a49c6f /src/backend/access/transam/xlogstats.c
parentb46efe90482bc1105a17955fce02cb3708230f0e (diff)
Clean up memory leakage that occurs in context callback functions.
An error context callback function might leak some memory into ErrorContext, since those functions are run with ErrorContext as current context. In the case where the elevel is ERROR, this is no problem since the code level that catches the error should do FlushErrorState to clean up, and that will reset ErrorContext. However, if the elevel is less than ERROR then no such cleanup occurs. In principle, repeated leaks while emitting log messages or client notices could accumulate arbitrarily much leaked data, if no ERROR occurs in the session. To fix, let errfinish() perform an ErrorContext reset if it is at the outermost error nesting level. (If it isn't, we'll delay cleanup until the outermost nesting level is exited.) The only actual leakage of this sort that I've been able to observe within our regression tests was recently introduced by commit f727b63e8. While it seems plausible that there are other such leaks not reached in the regression tests, the lack of field reports suggests that they're not a big problem. Accordingly, I won't take the risk of back-patching this now. We can always back-patch later if we get field reports of leaks. Reported-by: Andres Freund <andres@anarazel.de> Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/jngsjonyfscoont4tnwi2qoikatpd5hifsg373vmmjvugwiu6g@m6opxh7uisgd
Diffstat (limited to 'src/backend/access/transam/xlogstats.c')
0 files changed, 0 insertions, 0 deletions