pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Switch memory contexts in ReinitializeParallelDSM.
6+ messages / 1 participants
[nested] [flat]

* pgsql: Switch memory contexts in ReinitializeParallelDSM.
@ 2025-12-16 17:31 Robert Haas <rhaas@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Robert Haas @ 2025-12-16 17:31 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Switch memory contexts in ReinitializeParallelDSM.

We already do this in CreateParallelContext, InitializeParallelDSM, and
LaunchParallelWorkers. I suspect the reason why the matching logic was
omitted from ReinitializeParallelDSM is that I failed to realize that
any memory allocation was happening here -- but shm_mq_attach does
allocate, which could result in a shm_mq_handle being allocated in a
shorter-lived context than the ParallelContext which points to it.

That could result in a crash if the shorter-lived context is freed
before the parallel context is destroyed. As far as I am currently
aware, there is no way to reach a crash using only code that is
present in core PostgreSQL, but extensions could potentially trip
over this. Fixing this in the back-branches appears low-risk, so
back-patch to all supported versions.

Author: Jakub Wartak <jakub.wartak@enterprisedb.com>
Co-authored-by: Jeevan Chalke <jeevan.chalke@enterprisedb.com>
Backpatch-through: 14
Discussion: http://postgr.es/m/CAKZiRmwfVripa3FGo06=5D1EddpsLu9JY2iJOTgbsxUQ339ogQ@mail.gmail.com

Branch
------
master

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

Modified Files
--------------
src/backend/access/transam/parallel.c | 7 +++++++
1 file changed, 7 insertions(+)



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

* pgsql: Switch memory contexts in ReinitializeParallelDSM.
@ 2025-12-16 17:31 Robert Haas <rhaas@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Robert Haas @ 2025-12-16 17:31 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Switch memory contexts in ReinitializeParallelDSM.

We already do this in CreateParallelContext, InitializeParallelDSM, and
LaunchParallelWorkers. I suspect the reason why the matching logic was
omitted from ReinitializeParallelDSM is that I failed to realize that
any memory allocation was happening here -- but shm_mq_attach does
allocate, which could result in a shm_mq_handle being allocated in a
shorter-lived context than the ParallelContext which points to it.

That could result in a crash if the shorter-lived context is freed
before the parallel context is destroyed. As far as I am currently
aware, there is no way to reach a crash using only code that is
present in core PostgreSQL, but extensions could potentially trip
over this. Fixing this in the back-branches appears low-risk, so
back-patch to all supported versions.

Author: Jakub Wartak <jakub.wartak@enterprisedb.com>
Co-authored-by: Jeevan Chalke <jeevan.chalke@enterprisedb.com>
Backpatch-through: 14
Discussion: http://postgr.es/m/CAKZiRmwfVripa3FGo06=5D1EddpsLu9JY2iJOTgbsxUQ339ogQ@mail.gmail.com

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/57df5ab8049782d7b24594ac677783512ffce2bc

Modified Files
--------------
src/backend/access/transam/parallel.c | 7 +++++++
1 file changed, 7 insertions(+)



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

* pgsql: Switch memory contexts in ReinitializeParallelDSM.
@ 2025-12-16 17:31 Robert Haas <rhaas@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Robert Haas @ 2025-12-16 17:31 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Switch memory contexts in ReinitializeParallelDSM.

We already do this in CreateParallelContext, InitializeParallelDSM, and
LaunchParallelWorkers. I suspect the reason why the matching logic was
omitted from ReinitializeParallelDSM is that I failed to realize that
any memory allocation was happening here -- but shm_mq_attach does
allocate, which could result in a shm_mq_handle being allocated in a
shorter-lived context than the ParallelContext which points to it.

That could result in a crash if the shorter-lived context is freed
before the parallel context is destroyed. As far as I am currently
aware, there is no way to reach a crash using only code that is
present in core PostgreSQL, but extensions could potentially trip
over this. Fixing this in the back-branches appears low-risk, so
back-patch to all supported versions.

Author: Jakub Wartak <jakub.wartak@enterprisedb.com>
Co-authored-by: Jeevan Chalke <jeevan.chalke@enterprisedb.com>
Backpatch-through: 14
Discussion: http://postgr.es/m/CAKZiRmwfVripa3FGo06=5D1EddpsLu9JY2iJOTgbsxUQ339ogQ@mail.gmail.com

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1d0fc2499ff2f7b81e1e2c742ccb587c48d0f6d6

Modified Files
--------------
src/backend/access/transam/parallel.c | 7 +++++++
1 file changed, 7 insertions(+)



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

* pgsql: Switch memory contexts in ReinitializeParallelDSM.
@ 2025-12-16 17:31 Robert Haas <rhaas@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Robert Haas @ 2025-12-16 17:31 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Switch memory contexts in ReinitializeParallelDSM.

We already do this in CreateParallelContext, InitializeParallelDSM, and
LaunchParallelWorkers. I suspect the reason why the matching logic was
omitted from ReinitializeParallelDSM is that I failed to realize that
any memory allocation was happening here -- but shm_mq_attach does
allocate, which could result in a shm_mq_handle being allocated in a
shorter-lived context than the ParallelContext which points to it.

That could result in a crash if the shorter-lived context is freed
before the parallel context is destroyed. As far as I am currently
aware, there is no way to reach a crash using only code that is
present in core PostgreSQL, but extensions could potentially trip
over this. Fixing this in the back-branches appears low-risk, so
back-patch to all supported versions.

Author: Jakub Wartak <jakub.wartak@enterprisedb.com>
Co-authored-by: Jeevan Chalke <jeevan.chalke@enterprisedb.com>
Backpatch-through: 14
Discussion: http://postgr.es/m/CAKZiRmwfVripa3FGo06=5D1EddpsLu9JY2iJOTgbsxUQ339ogQ@mail.gmail.com

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/12c2f843cddae802302cb1a197a5b80dd5b3a04c

Modified Files
--------------
src/backend/access/transam/parallel.c | 7 +++++++
1 file changed, 7 insertions(+)



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

* pgsql: Switch memory contexts in ReinitializeParallelDSM.
@ 2025-12-16 17:31 Robert Haas <rhaas@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Robert Haas @ 2025-12-16 17:31 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Switch memory contexts in ReinitializeParallelDSM.

We already do this in CreateParallelContext, InitializeParallelDSM, and
LaunchParallelWorkers. I suspect the reason why the matching logic was
omitted from ReinitializeParallelDSM is that I failed to realize that
any memory allocation was happening here -- but shm_mq_attach does
allocate, which could result in a shm_mq_handle being allocated in a
shorter-lived context than the ParallelContext which points to it.

That could result in a crash if the shorter-lived context is freed
before the parallel context is destroyed. As far as I am currently
aware, there is no way to reach a crash using only code that is
present in core PostgreSQL, but extensions could potentially trip
over this. Fixing this in the back-branches appears low-risk, so
back-patch to all supported versions.

Author: Jakub Wartak <jakub.wartak@enterprisedb.com>
Co-authored-by: Jeevan Chalke <jeevan.chalke@enterprisedb.com>
Backpatch-through: 14
Discussion: http://postgr.es/m/CAKZiRmwfVripa3FGo06=5D1EddpsLu9JY2iJOTgbsxUQ339ogQ@mail.gmail.com

Branch
------
REL_15_STABLE

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

Modified Files
--------------
src/backend/access/transam/parallel.c | 7 +++++++
1 file changed, 7 insertions(+)



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

* pgsql: Switch memory contexts in ReinitializeParallelDSM.
@ 2025-12-16 17:31 Robert Haas <rhaas@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Robert Haas @ 2025-12-16 17:31 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Switch memory contexts in ReinitializeParallelDSM.

We already do this in CreateParallelContext, InitializeParallelDSM, and
LaunchParallelWorkers. I suspect the reason why the matching logic was
omitted from ReinitializeParallelDSM is that I failed to realize that
any memory allocation was happening here -- but shm_mq_attach does
allocate, which could result in a shm_mq_handle being allocated in a
shorter-lived context than the ParallelContext which points to it.

That could result in a crash if the shorter-lived context is freed
before the parallel context is destroyed. As far as I am currently
aware, there is no way to reach a crash using only code that is
present in core PostgreSQL, but extensions could potentially trip
over this. Fixing this in the back-branches appears low-risk, so
back-patch to all supported versions.

Author: Jakub Wartak <jakub.wartak@enterprisedb.com>
Co-authored-by: Jeevan Chalke <jeevan.chalke@enterprisedb.com>
Backpatch-through: 14
Discussion: http://postgr.es/m/CAKZiRmwfVripa3FGo06=5D1EddpsLu9JY2iJOTgbsxUQ339ogQ@mail.gmail.com

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1d9f7fbba24c78eaa431fbe7fe14340793ade015

Modified Files
--------------
src/backend/access/transam/parallel.c | 7 +++++++
1 file changed, 7 insertions(+)



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


end of thread, other threads:[~2025-12-16 17:31 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-12-16 17:31 pgsql: Switch memory contexts in ReinitializeParallelDSM. Robert Haas <rhaas@postgresql.org>
2025-12-16 17:31 pgsql: Switch memory contexts in ReinitializeParallelDSM. Robert Haas <rhaas@postgresql.org>
2025-12-16 17:31 pgsql: Switch memory contexts in ReinitializeParallelDSM. Robert Haas <rhaas@postgresql.org>
2025-12-16 17:31 pgsql: Switch memory contexts in ReinitializeParallelDSM. Robert Haas <rhaas@postgresql.org>
2025-12-16 17:31 pgsql: Switch memory contexts in ReinitializeParallelDSM. Robert Haas <rhaas@postgresql.org>
2025-12-16 17:31 pgsql: Switch memory contexts in ReinitializeParallelDSM. Robert Haas <rhaas@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