pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix waitpid() emulation on Windows. 6+ messages / 1 participants [nested] [flat]
* pgsql: Fix waitpid() emulation on Windows. @ 2023-03-15 00:45 Thomas Munro <tmunro@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Thomas Munro @ 2023-03-15 00:45 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix waitpid() emulation on Windows. Our waitpid() emulation didn't prevent a PID from being recycled by the OS before the call to waitpid(). The postmaster could finish up tracking more than one child process with the same PID, and confuse them. Fix, by moving the guts of pgwin32_deadchild_callback() into waitpid(), so that resources are released synchronously. The process and PID continue to exist until we close the process handle, which only happens once we're ready to adjust our book-keeping of running children. This seems to explain a couple of failures on CI. It had never been reported before, despite the code being as old as the Windows port. Perhaps Windows started recycling PIDs more rapidly, or perhaps timing changes due to commit 7389aad6 made it more likely to break. Thanks to Alexander Lakhin for analysis and Andres Freund for tracking down the root cause. Back-patch to all supported branches. Reported-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/20230208012852.bvkn2am4h4iqjogq%40awork3.anarazel.de Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/d41a178b3a7ac0c2ca16f70129899ddabc2ce468 Modified Files -------------- src/backend/postmaster/postmaster.c | 70 +++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 30 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix waitpid() emulation on Windows. @ 2023-03-15 00:45 Thomas Munro <tmunro@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Thomas Munro @ 2023-03-15 00:45 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix waitpid() emulation on Windows. Our waitpid() emulation didn't prevent a PID from being recycled by the OS before the call to waitpid(). The postmaster could finish up tracking more than one child process with the same PID, and confuse them. Fix, by moving the guts of pgwin32_deadchild_callback() into waitpid(), so that resources are released synchronously. The process and PID continue to exist until we close the process handle, which only happens once we're ready to adjust our book-keeping of running children. This seems to explain a couple of failures on CI. It had never been reported before, despite the code being as old as the Windows port. Perhaps Windows started recycling PIDs more rapidly, or perhaps timing changes due to commit 7389aad6 made it more likely to break. Thanks to Alexander Lakhin for analysis and Andres Freund for tracking down the root cause. Back-patch to all supported branches. Reported-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/20230208012852.bvkn2am4h4iqjogq%40awork3.anarazel.de Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/06066915d48f072dcc5add048569ee7206772275 Modified Files -------------- src/backend/postmaster/postmaster.c | 70 +++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 30 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix waitpid() emulation on Windows. @ 2023-03-15 00:45 Thomas Munro <tmunro@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Thomas Munro @ 2023-03-15 00:45 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix waitpid() emulation on Windows. Our waitpid() emulation didn't prevent a PID from being recycled by the OS before the call to waitpid(). The postmaster could finish up tracking more than one child process with the same PID, and confuse them. Fix, by moving the guts of pgwin32_deadchild_callback() into waitpid(), so that resources are released synchronously. The process and PID continue to exist until we close the process handle, which only happens once we're ready to adjust our book-keeping of running children. This seems to explain a couple of failures on CI. It had never been reported before, despite the code being as old as the Windows port. Perhaps Windows started recycling PIDs more rapidly, or perhaps timing changes due to commit 7389aad6 made it more likely to break. Thanks to Alexander Lakhin for analysis and Andres Freund for tracking down the root cause. Back-patch to all supported branches. Reported-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/20230208012852.bvkn2am4h4iqjogq%40awork3.anarazel.de Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/9b6e0b9c37d644bc99f7c79e01b388f6a3648387 Modified Files -------------- src/backend/postmaster/postmaster.c | 70 +++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 30 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix waitpid() emulation on Windows. @ 2023-03-15 00:45 Thomas Munro <tmunro@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Thomas Munro @ 2023-03-15 00:45 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix waitpid() emulation on Windows. Our waitpid() emulation didn't prevent a PID from being recycled by the OS before the call to waitpid(). The postmaster could finish up tracking more than one child process with the same PID, and confuse them. Fix, by moving the guts of pgwin32_deadchild_callback() into waitpid(), so that resources are released synchronously. The process and PID continue to exist until we close the process handle, which only happens once we're ready to adjust our book-keeping of running children. This seems to explain a couple of failures on CI. It had never been reported before, despite the code being as old as the Windows port. Perhaps Windows started recycling PIDs more rapidly, or perhaps timing changes due to commit 7389aad6 made it more likely to break. Thanks to Alexander Lakhin for analysis and Andres Freund for tracking down the root cause. Back-patch to all supported branches. Reported-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/20230208012852.bvkn2am4h4iqjogq%40awork3.anarazel.de Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/9f1c64018549e28a6f6aa5ad0d5917085520efdd Modified Files -------------- src/backend/postmaster/postmaster.c | 70 +++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 30 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix waitpid() emulation on Windows. @ 2023-03-15 00:45 Thomas Munro <tmunro@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Thomas Munro @ 2023-03-15 00:45 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix waitpid() emulation on Windows. Our waitpid() emulation didn't prevent a PID from being recycled by the OS before the call to waitpid(). The postmaster could finish up tracking more than one child process with the same PID, and confuse them. Fix, by moving the guts of pgwin32_deadchild_callback() into waitpid(), so that resources are released synchronously. The process and PID continue to exist until we close the process handle, which only happens once we're ready to adjust our book-keeping of running children. This seems to explain a couple of failures on CI. It had never been reported before, despite the code being as old as the Windows port. Perhaps Windows started recycling PIDs more rapidly, or perhaps timing changes due to commit 7389aad6 made it more likely to break. Thanks to Alexander Lakhin for analysis and Andres Freund for tracking down the root cause. Back-patch to all supported branches. Reported-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/20230208012852.bvkn2am4h4iqjogq%40awork3.anarazel.de Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/8362884275b5ba0620b1edfff260078910159c98 Modified Files -------------- src/backend/postmaster/postmaster.c | 70 +++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 30 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix waitpid() emulation on Windows. @ 2023-03-15 00:46 Thomas Munro <tmunro@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Thomas Munro @ 2023-03-15 00:46 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix waitpid() emulation on Windows. Our waitpid() emulation didn't prevent a PID from being recycled by the OS before the call to waitpid(). The postmaster could finish up tracking more than one child process with the same PID, and confuse them. Fix, by moving the guts of pgwin32_deadchild_callback() into waitpid(), so that resources are released synchronously. The process and PID continue to exist until we close the process handle, which only happens once we're ready to adjust our book-keeping of running children. This seems to explain a couple of failures on CI. It had never been reported before, despite the code being as old as the Windows port. Perhaps Windows started recycling PIDs more rapidly, or perhaps timing changes due to commit 7389aad6 made it more likely to break. Thanks to Alexander Lakhin for analysis and Andres Freund for tracking down the root cause. Back-patch to all supported branches. Reported-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/20230208012852.bvkn2am4h4iqjogq%40awork3.anarazel.de Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/5ff8e69d8ea594075e435bb42e95b605e08afc2f Modified Files -------------- src/backend/postmaster/postmaster.c | 70 +++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 30 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2023-03-15 00:46 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2023-03-15 00:45 pgsql: Fix waitpid() emulation on Windows. Thomas Munro <tmunro@postgresql.org> 2023-03-15 00:45 pgsql: Fix waitpid() emulation on Windows. Thomas Munro <tmunro@postgresql.org> 2023-03-15 00:45 pgsql: Fix waitpid() emulation on Windows. Thomas Munro <tmunro@postgresql.org> 2023-03-15 00:45 pgsql: Fix waitpid() emulation on Windows. Thomas Munro <tmunro@postgresql.org> 2023-03-15 00:45 pgsql: Fix waitpid() emulation on Windows. Thomas Munro <tmunro@postgresql.org> 2023-03-15 00:46 pgsql: Fix waitpid() emulation on Windows. Thomas Munro <tmunro@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