pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix memory leak in Incremental Sort rescans 5+ messages / 1 participants [nested] [flat]
* pgsql: Fix memory leak in Incremental Sort rescans @ 2023-07-02 18:03 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 5+ messages in thread From: Tomas Vondra @ 2023-07-02 18:03 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix memory leak in Incremental Sort rescans The Incremental Sort had a couple issues, resulting in leaking memory during rescans, possibly triggering OOM. The code had a couple of related flaws: 1. During rescans, the sort states were reset but then also set to NULL (despite the comment saying otherwise). ExecIncrementalSort then sees NULL and initializes a new sort state, leaking the memory used by the old one. 2. Initializing the sort state also automatically rebuilt the info about presorted keys, leaking the already initialized info. presorted_keys was also unnecessarily reset to NULL. Patch by James Coleman, based on patches by Laurenz Albe and Tom Lane. Backpatch to 13, where Incremental Sort was introduced. Author: James Coleman, Laurenz Albe, Tom Lane Reported-by: Laurenz Albe, Zu-Ming Jiang Backpatch-through: 13 Discussion: https://postgr.es/m/b2bd02dff61af15e3526293e2771f874cf2a3be7.camel%40cybertec.at Discussion: https://postgr.es/m/db03c582-086d-e7cd-d4a1-3bc722f81765%40inf.ethz.ch Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/98640f960eb9ed80cf90de3ef5d2e829b785b3eb Modified Files -------------- src/backend/executor/nodeIncrementalSort.c | 7 ------- 1 file changed, 7 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix memory leak in Incremental Sort rescans @ 2023-07-02 18:04 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 5+ messages in thread From: Tomas Vondra @ 2023-07-02 18:04 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix memory leak in Incremental Sort rescans The Incremental Sort had a couple issues, resulting in leaking memory during rescans, possibly triggering OOM. The code had a couple of related flaws: 1. During rescans, the sort states were reset but then also set to NULL (despite the comment saying otherwise). ExecIncrementalSort then sees NULL and initializes a new sort state, leaking the memory used by the old one. 2. Initializing the sort state also automatically rebuilt the info about presorted keys, leaking the already initialized info. presorted_keys was also unnecessarily reset to NULL. Patch by James Coleman, based on patches by Laurenz Albe and Tom Lane. Backpatch to 13, where Incremental Sort was introduced. Author: James Coleman, Laurenz Albe, Tom Lane Reported-by: Laurenz Albe, Zu-Ming Jiang Backpatch-through: 13 Discussion: https://postgr.es/m/b2bd02dff61af15e3526293e2771f874cf2a3be7.camel%40cybertec.at Discussion: https://postgr.es/m/db03c582-086d-e7cd-d4a1-3bc722f81765%40inf.ethz.ch Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/9ae7b5d1f3ad2dc31ba7552a19d2efb24e7dbc0e Modified Files -------------- src/backend/executor/nodeIncrementalSort.c | 7 ------- 1 file changed, 7 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix memory leak in Incremental Sort rescans @ 2023-07-02 18:04 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 5+ messages in thread From: Tomas Vondra @ 2023-07-02 18:04 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix memory leak in Incremental Sort rescans The Incremental Sort had a couple issues, resulting in leaking memory during rescans, possibly triggering OOM. The code had a couple of related flaws: 1. During rescans, the sort states were reset but then also set to NULL (despite the comment saying otherwise). ExecIncrementalSort then sees NULL and initializes a new sort state, leaking the memory used by the old one. 2. Initializing the sort state also automatically rebuilt the info about presorted keys, leaking the already initialized info. presorted_keys was also unnecessarily reset to NULL. Patch by James Coleman, based on patches by Laurenz Albe and Tom Lane. Backpatch to 13, where Incremental Sort was introduced. Author: James Coleman, Laurenz Albe, Tom Lane Reported-by: Laurenz Albe, Zu-Ming Jiang Backpatch-through: 13 Discussion: https://postgr.es/m/b2bd02dff61af15e3526293e2771f874cf2a3be7.camel%40cybertec.at Discussion: https://postgr.es/m/db03c582-086d-e7cd-d4a1-3bc722f81765%40inf.ethz.ch Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/0c5fe4ff6b2b3daf08676d7939f1d7f3a6235212 Modified Files -------------- src/backend/executor/nodeIncrementalSort.c | 7 ------- 1 file changed, 7 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix memory leak in Incremental Sort rescans @ 2023-07-02 18:05 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 5+ messages in thread From: Tomas Vondra @ 2023-07-02 18:05 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix memory leak in Incremental Sort rescans The Incremental Sort had a couple issues, resulting in leaking memory during rescans, possibly triggering OOM. The code had a couple of related flaws: 1. During rescans, the sort states were reset but then also set to NULL (despite the comment saying otherwise). ExecIncrementalSort then sees NULL and initializes a new sort state, leaking the memory used by the old one. 2. Initializing the sort state also automatically rebuilt the info about presorted keys, leaking the already initialized info. presorted_keys was also unnecessarily reset to NULL. Patch by James Coleman, based on patches by Laurenz Albe and Tom Lane. Backpatch to 13, where Incremental Sort was introduced. Author: James Coleman, Laurenz Albe, Tom Lane Reported-by: Laurenz Albe, Zu-Ming Jiang Backpatch-through: 13 Discussion: https://postgr.es/m/b2bd02dff61af15e3526293e2771f874cf2a3be7.camel%40cybertec.at Discussion: https://postgr.es/m/db03c582-086d-e7cd-d4a1-3bc722f81765%40inf.ethz.ch Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/c1affa38c73b432d358c5b19b697e03a59b355ab Modified Files -------------- src/backend/executor/nodeIncrementalSort.c | 7 ------- 1 file changed, 7 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix memory leak in Incremental Sort rescans @ 2023-07-02 18:05 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 5+ messages in thread From: Tomas Vondra @ 2023-07-02 18:05 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix memory leak in Incremental Sort rescans The Incremental Sort had a couple issues, resulting in leaking memory during rescans, possibly triggering OOM. The code had a couple of related flaws: 1. During rescans, the sort states were reset but then also set to NULL (despite the comment saying otherwise). ExecIncrementalSort then sees NULL and initializes a new sort state, leaking the memory used by the old one. 2. Initializing the sort state also automatically rebuilt the info about presorted keys, leaking the already initialized info. presorted_keys was also unnecessarily reset to NULL. Patch by James Coleman, based on patches by Laurenz Albe and Tom Lane. Backpatch to 13, where Incremental Sort was introduced. Author: James Coleman, Laurenz Albe, Tom Lane Reported-by: Laurenz Albe, Zu-Ming Jiang Backpatch-through: 13 Discussion: https://postgr.es/m/b2bd02dff61af15e3526293e2771f874cf2a3be7.camel%40cybertec.at Discussion: https://postgr.es/m/db03c582-086d-e7cd-d4a1-3bc722f81765%40inf.ethz.ch Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/3ce761d5cafeb0d63f2cb0e9876ba1578c1333c5 Modified Files -------------- src/backend/executor/nodeIncrementalSort.c | 7 ------- 1 file changed, 7 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2023-07-02 18:05 UTC | newest] Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2023-07-02 18:03 pgsql: Fix memory leak in Incremental Sort rescans Tomas Vondra <tomas.vondra@postgresql.org> 2023-07-02 18:04 pgsql: Fix memory leak in Incremental Sort rescans Tomas Vondra <tomas.vondra@postgresql.org> 2023-07-02 18:04 pgsql: Fix memory leak in Incremental Sort rescans Tomas Vondra <tomas.vondra@postgresql.org> 2023-07-02 18:05 pgsql: Fix memory leak in Incremental Sort rescans Tomas Vondra <tomas.vondra@postgresql.org> 2023-07-02 18:05 pgsql: Fix memory leak in Incremental Sort rescans Tomas Vondra <tomas.vondra@postgresql.org>
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