Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbfaaacc

Browse files
committed
Improve plpgsql's memory management to fix some function-lifespan leaks.
In some cases, exiting out of a plpgsql statement due to an error, thencatching the error in a surrounding exception block, led to leakage oftemporary data the statement was working with, because we kept all suchdata in the function-lifespan SPI Proc context. Iterating such behaviormany times within one function call thus led to noticeable memory bloat.To fix, create an additional memory context meant to have statementlifespan. Since many plpgsql statements, particularly the simpler/morecommon ones, don't need this, create it only on demand. Reset this contextat the end of any statement that uses it, and arrange for exception cleanupto reset it too, thereby fixing the memory-leak issue. Allow a stack ofsuch contexts to exist to handle cases where a compound statement needsstatement-lifespan data that persists across calls of inner statements.While at it, clean up code and improve comments referring to the existingshort-term memory context, which by plpgsql convention is the per-tuplecontext of the eval_econtext ExprContext. We now uniformly refer to thatas the eval_mcontext, whereas the new statement-lifespan memory contextsare called stmt_mcontext.This change adds some context-creation overhead, but on the other handit allows removal of some retail pfree's in favor of context resets.On balance it seems to be about a wash performance-wise.In principle this is a bug fix, but it seems too invasive for a back-patch,and the infrequency of complaints weighs against taking the risk in theback branches. So we'll fix it only in HEAD, at least for now.Tom Lane, reviewed by Pavel StehuleDiscussion: <17863.1469142152@sss.pgh.pa.us>
1 parent0921554 commitbfaaacc

File tree

2 files changed

+403
-193
lines changed

2 files changed

+403
-193
lines changed

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp