[pgpool-committers: 5556] pgpool: Fix memory leak in "batch" mode in extended query.

Tatsuo Ishii ishii at sraoss.co.jp
Thu Mar 28 14:14:37 JST 2019

Fix memory leak in "batch" mode in extended query.

In "batch" mode, not for every execute message, a sync message is
followed.  Unfortunately Pgpool-II only discard memory of query
context for the last execute message while processing the ready for
query message. For example if 3 execute messages are sent before the
sync message, 2 of query context memory will not be freed and this
leads to serious memory leak.

To fix the problem, now the query context memory is possibly discarded
when a command complete message is returned from backend if the query
context is not referenced either by sent messages or pending messages.
If it is not referenced at all, we can discard the query context.

Also even if it is referenced, it is ok to discard the query context
if it is either an unnamed statement or an unnamed portal because it
will be discarded anyway when next unnamed statement or portal is

Per bug 468.



Modified Files
src/context/pool_query_context.c           |  3 +-
src/context/pool_session_context.c         | 49 +++++++++++++++++++++++++++++-
src/include/context/pool_session_context.h |  2 ++
src/protocol/CommandComplete.c             | 25 +++++++++++++++
4 files changed, 77 insertions(+), 2 deletions(-)

More information about the pgpool-committers mailing list