pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Revise RelationBuildRowSecurity() to avoid memory leaks.
7+ messages / 1 participants
[nested] [flat]

* pgsql: Revise RelationBuildRowSecurity() to avoid memory leaks.
@ 2020-09-26 20:04 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-09-26 20:04 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Revise RelationBuildRowSecurity() to avoid memory leaks.

This function leaked some memory while loading qual clauses for
an RLS policy.  While ordinarily negligible, that could build up
in some repeated-reload cases, as reported by Konstantin Knizhnik.
We can improve matters by borrowing the coding long used in
RelationBuildRuleLock: build stringToNode's result directly in
the target context, and remember to explicitly pfree the
input string.

This patch by no means completely guarantees zero leaks within
this function, since we have no real guarantee that the catalog-
reading subroutines it calls don't leak anything.  However,
practical tests suggest that this is enough to resolve the issue.
In any case, any remaining leaks are similar to those risked by
RelationBuildRuleLock and other relcache-loading subroutines.
If we need to fix them, we should adopt a more global approach
such as that used by the RECOVER_RELATION_BUILD_MEMORY hack.

While here, let's remove the need for an expensive PG_TRY block by
using MemoryContextSetParent to reparent an initially-short-lived
context for the RLS data.

Back-patch to all supported branches.

Discussion: https://postgr.es/m/21356c12-8917-8249-b35f-1c447231922b@postgrespro.ru

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e55f718fc429fb7971eb7351debfa5931f9811bf

Modified Files
--------------
src/backend/commands/policy.c | 216 +++++++++++++++++++-----------------------
1 file changed, 98 insertions(+), 118 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Revise RelationBuildRowSecurity() to avoid memory leaks.
@ 2020-09-26 20:04 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-09-26 20:04 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Revise RelationBuildRowSecurity() to avoid memory leaks.

This function leaked some memory while loading qual clauses for
an RLS policy.  While ordinarily negligible, that could build up
in some repeated-reload cases, as reported by Konstantin Knizhnik.
We can improve matters by borrowing the coding long used in
RelationBuildRuleLock: build stringToNode's result directly in
the target context, and remember to explicitly pfree the
input string.

This patch by no means completely guarantees zero leaks within
this function, since we have no real guarantee that the catalog-
reading subroutines it calls don't leak anything.  However,
practical tests suggest that this is enough to resolve the issue.
In any case, any remaining leaks are similar to those risked by
RelationBuildRuleLock and other relcache-loading subroutines.
If we need to fix them, we should adopt a more global approach
such as that used by the RECOVER_RELATION_BUILD_MEMORY hack.

While here, let's remove the need for an expensive PG_TRY block by
using MemoryContextSetParent to reparent an initially-short-lived
context for the RLS data.

Back-patch to all supported branches.

Discussion: https://postgr.es/m/21356c12-8917-8249-b35f-1c447231922b@postgrespro.ru

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f7873900f353ff210ef2ef2aa587e39196b8bf5a

Modified Files
--------------
src/backend/commands/policy.c | 216 +++++++++++++++++++-----------------------
1 file changed, 98 insertions(+), 118 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Revise RelationBuildRowSecurity() to avoid memory leaks.
@ 2020-09-26 20:04 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-09-26 20:04 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Revise RelationBuildRowSecurity() to avoid memory leaks.

This function leaked some memory while loading qual clauses for
an RLS policy.  While ordinarily negligible, that could build up
in some repeated-reload cases, as reported by Konstantin Knizhnik.
We can improve matters by borrowing the coding long used in
RelationBuildRuleLock: build stringToNode's result directly in
the target context, and remember to explicitly pfree the
input string.

This patch by no means completely guarantees zero leaks within
this function, since we have no real guarantee that the catalog-
reading subroutines it calls don't leak anything.  However,
practical tests suggest that this is enough to resolve the issue.
In any case, any remaining leaks are similar to those risked by
RelationBuildRuleLock and other relcache-loading subroutines.
If we need to fix them, we should adopt a more global approach
such as that used by the RECOVER_RELATION_BUILD_MEMORY hack.

While here, let's remove the need for an expensive PG_TRY block by
using MemoryContextSetParent to reparent an initially-short-lived
context for the RLS data.

Back-patch to all supported branches.

Discussion: https://postgr.es/m/21356c12-8917-8249-b35f-1c447231922b@postgrespro.ru

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/bda32733ceeb0687ee5a1e734005270b1dee66a7

Modified Files
--------------
src/backend/commands/policy.c | 216 +++++++++++++++++++-----------------------
1 file changed, 98 insertions(+), 118 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Revise RelationBuildRowSecurity() to avoid memory leaks.
@ 2020-09-26 20:04 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-09-26 20:04 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Revise RelationBuildRowSecurity() to avoid memory leaks.

This function leaked some memory while loading qual clauses for
an RLS policy.  While ordinarily negligible, that could build up
in some repeated-reload cases, as reported by Konstantin Knizhnik.
We can improve matters by borrowing the coding long used in
RelationBuildRuleLock: build stringToNode's result directly in
the target context, and remember to explicitly pfree the
input string.

This patch by no means completely guarantees zero leaks within
this function, since we have no real guarantee that the catalog-
reading subroutines it calls don't leak anything.  However,
practical tests suggest that this is enough to resolve the issue.
In any case, any remaining leaks are similar to those risked by
RelationBuildRuleLock and other relcache-loading subroutines.
If we need to fix them, we should adopt a more global approach
such as that used by the RECOVER_RELATION_BUILD_MEMORY hack.

While here, let's remove the need for an expensive PG_TRY block by
using MemoryContextSetParent to reparent an initially-short-lived
context for the RLS data.

Back-patch to all supported branches.

Discussion: https://postgr.es/m/21356c12-8917-8249-b35f-1c447231922b@postgrespro.ru

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/dd89ba5780214e5f0d9b222e242141fe99cfcdd9

Modified Files
--------------
src/backend/commands/policy.c | 216 +++++++++++++++++++-----------------------
1 file changed, 98 insertions(+), 118 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Revise RelationBuildRowSecurity() to avoid memory leaks.
@ 2020-09-26 20:04 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-09-26 20:04 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Revise RelationBuildRowSecurity() to avoid memory leaks.

This function leaked some memory while loading qual clauses for
an RLS policy.  While ordinarily negligible, that could build up
in some repeated-reload cases, as reported by Konstantin Knizhnik.
We can improve matters by borrowing the coding long used in
RelationBuildRuleLock: build stringToNode's result directly in
the target context, and remember to explicitly pfree the
input string.

This patch by no means completely guarantees zero leaks within
this function, since we have no real guarantee that the catalog-
reading subroutines it calls don't leak anything.  However,
practical tests suggest that this is enough to resolve the issue.
In any case, any remaining leaks are similar to those risked by
RelationBuildRuleLock and other relcache-loading subroutines.
If we need to fix them, we should adopt a more global approach
such as that used by the RECOVER_RELATION_BUILD_MEMORY hack.

While here, let's remove the need for an expensive PG_TRY block by
using MemoryContextSetParent to reparent an initially-short-lived
context for the RLS data.

Back-patch to all supported branches.

Discussion: https://postgr.es/m/21356c12-8917-8249-b35f-1c447231922b@postgrespro.ru

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/de6725debd00504fa71a43f718acb26bb045b07f

Modified Files
--------------
src/backend/commands/policy.c | 211 +++++++++++++++++++-----------------------
1 file changed, 96 insertions(+), 115 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Revise RelationBuildRowSecurity() to avoid memory leaks.
@ 2020-09-26 20:04 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-09-26 20:04 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Revise RelationBuildRowSecurity() to avoid memory leaks.

This function leaked some memory while loading qual clauses for
an RLS policy.  While ordinarily negligible, that could build up
in some repeated-reload cases, as reported by Konstantin Knizhnik.
We can improve matters by borrowing the coding long used in
RelationBuildRuleLock: build stringToNode's result directly in
the target context, and remember to explicitly pfree the
input string.

This patch by no means completely guarantees zero leaks within
this function, since we have no real guarantee that the catalog-
reading subroutines it calls don't leak anything.  However,
practical tests suggest that this is enough to resolve the issue.
In any case, any remaining leaks are similar to those risked by
RelationBuildRuleLock and other relcache-loading subroutines.
If we need to fix them, we should adopt a more global approach
such as that used by the RECOVER_RELATION_BUILD_MEMORY hack.

While here, let's remove the need for an expensive PG_TRY block by
using MemoryContextSetParent to reparent an initially-short-lived
context for the RLS data.

Back-patch to all supported branches.

Discussion: https://postgr.es/m/21356c12-8917-8249-b35f-1c447231922b@postgrespro.ru

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/acab757ce9ead47a39b4d2d25b91ed2532b8444a

Modified Files
--------------
src/backend/commands/policy.c | 204 ++++++++++++++++++++----------------------
1 file changed, 95 insertions(+), 109 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Revise RelationBuildRowSecurity() to avoid memory leaks.
@ 2020-09-26 20:04 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-09-26 20:04 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Revise RelationBuildRowSecurity() to avoid memory leaks.

This function leaked some memory while loading qual clauses for
an RLS policy.  While ordinarily negligible, that could build up
in some repeated-reload cases, as reported by Konstantin Knizhnik.
We can improve matters by borrowing the coding long used in
RelationBuildRuleLock: build stringToNode's result directly in
the target context, and remember to explicitly pfree the
input string.

This patch by no means completely guarantees zero leaks within
this function, since we have no real guarantee that the catalog-
reading subroutines it calls don't leak anything.  However,
practical tests suggest that this is enough to resolve the issue.
In any case, any remaining leaks are similar to those risked by
RelationBuildRuleLock and other relcache-loading subroutines.
If we need to fix them, we should adopt a more global approach
such as that used by the RECOVER_RELATION_BUILD_MEMORY hack.

While here, let's remove the need for an expensive PG_TRY block by
using MemoryContextSetParent to reparent an initially-short-lived
context for the RLS data.

Back-patch to all supported branches.

Discussion: https://postgr.es/m/21356c12-8917-8249-b35f-1c447231922b@postgrespro.ru

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/bf34ae930deeafcca2a9ed8b984061806451e2f1

Modified Files
--------------
src/backend/commands/policy.c | 204 ++++++++++++++++++++----------------------
1 file changed, 95 insertions(+), 109 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2020-09-26 20:04 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-09-26 20:04 pgsql: Revise RelationBuildRowSecurity() to avoid memory leaks. Tom Lane <tgl@sss.pgh.pa.us>
2020-09-26 20:04 pgsql: Revise RelationBuildRowSecurity() to avoid memory leaks. Tom Lane <tgl@sss.pgh.pa.us>
2020-09-26 20:04 pgsql: Revise RelationBuildRowSecurity() to avoid memory leaks. Tom Lane <tgl@sss.pgh.pa.us>
2020-09-26 20:04 pgsql: Revise RelationBuildRowSecurity() to avoid memory leaks. Tom Lane <tgl@sss.pgh.pa.us>
2020-09-26 20:04 pgsql: Revise RelationBuildRowSecurity() to avoid memory leaks. Tom Lane <tgl@sss.pgh.pa.us>
2020-09-26 20:04 pgsql: Revise RelationBuildRowSecurity() to avoid memory leaks. Tom Lane <tgl@sss.pgh.pa.us>
2020-09-26 20:04 pgsql: Revise RelationBuildRowSecurity() to avoid memory leaks. Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox