pgsql: Fix memory leak in repeated SPGIST index scans.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix memory leak in repeated SPGIST index scans.
Дата
Msg-id E1gHxg1-0007B7-Gt@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix memory leak in repeated SPGIST index scans.

spgendscan neglected to pfree all the memory allocated by spgbeginscan.
It's possible to get away with that in most normal queries, since the
memory is allocated in the executor's per-query context which is about
to get deleted anyway; but it causes severe memory leakage during
creation or filling of large exclusion-constraint indexes.

Also, document that amendscan is supposed to free what ambeginscan
allocates.  The docs' lack of clarity on that point probably caused this
bug to begin with.  (There is discussion of changing that API spec going
forward, but I don't think it'd be appropriate for the back branches.)

Per report from Bruno Wolff.  It's been like this since the beginning,
so back-patch to all active branches.

In HEAD, also fix an independent leak caused by commit 2a6368343
(allocating memory during spgrescan instead of spgbeginscan, which
might be all right if it got cleaned up, but it didn't).  And do a bit
of code beautification on that commit, too.

Discussion: https://postgr.es/m/20181024012314.GA27428@wolff.to

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/696b0c5fd0a8765fe6dfd075a30be06b448fd615

Modified Files
--------------
doc/src/sgml/indexam.sgml           |  3 ++-
src/backend/access/spgist/spgscan.c | 35 ++++++++++++++++++++++++++++-------
2 files changed, 30 insertions(+), 8 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: pgsql: Fix typo in xlog.c.
Следующее
От: Andres Freund
Дата:
Сообщение: pgsql: Disallow starting server with insufficient wal_level forexistin