pgsql: Fix memory leak in LogStandbySnapshot(). - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix memory leak in LogStandbySnapshot().
Date
Msg-id E1UjwS5-0000Fx-94@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix memory leak in LogStandbySnapshot().

The array allocated by GetRunningTransactionLocks() needs to be pfree'd
when we're done with it.  Otherwise we leak some memory during each
checkpoint, if wal_level = hot_standby.  This manifests as memory bloat
in the checkpointer process, or in bgwriter in versions before we made
the checkpointer separate.

Reported and fixed by Naoya Anzai.  Back-patch to 9.0 where the issue
was introduced.

In passing, improve comments for GetRunningTransactionLocks(), and add
an Assert that we didn't overrun the palloc'd array.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/dbc6eb1f4b840d252031419d4bf694316812124f

Modified Files
--------------
src/backend/storage/ipc/standby.c |    7 +------
src/backend/storage/lmgr/lock.c   |   16 +++++++++++++---
2 files changed, 14 insertions(+), 9 deletions(-)


pgsql-committers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: pgsql: Fix off-by-one in pg_xlogdump -r option.
Next
From: Tom Lane
Date:
Subject: pgsql: Fix memory leak in LogStandbySnapshot().