pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Report failure to start a background worker. 5+ messages / 1 participants [nested] [flat]
* pgsql: Report failure to start a background worker. @ 2017-12-06 14:11 Robert Haas <rhaas@postgresql.org> 0 siblings, 0 replies; 5+ messages in thread From: Robert Haas @ 2017-12-06 14:11 UTC (permalink / raw) To: pgsql-committers Report failure to start a background worker. When a worker is flagged as BGW_NEVER_RESTART and we fail to start it, or if it is not marked BGW_NEVER_RESTART but is terminated before startup succeeds, what BgwHandleStatus should be reported? The previous code really hadn't considered this possibility (as indicated by the comments which ignore it completely) and would typically return BGWH_NOT_YET_STARTED, but that's not a good answer, because then there's no way for code using GetBackgroundWorkerPid() to tell the difference between a worker that has not started but will start later and a worker that has not started and will never be started. So, when this case happens, return BGWH_STOPPED instead. Update the comments to reflect this. The preceding fix by itself is insufficient to fix the problem, because the old code also didn't send a notification to the process identified in bgw_notify_pid when startup failed. That might've been technically correct under the theory that the status of the worker was BGWH_NOT_YET_STARTED, because the status would indeed not change when the worker failed to start, but now that we're more usefully reporting BGWH_STOPPED, a notification is needed. Without these fixes, code which starts background workers and then uses the recommended APIs to wait for those background workers to start would hang indefinitely if the postmaster failed to fork a worker. Amit Kapila and Robert Haas Discussion: http://postgr.es/m/CAA4eK1KDfKkvrjxsKJi3WPyceVi3dH1VCkbTJji2fuwKuB=3uw@mail.gmail.com Branch ------ REL9_6_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/b75644066091784eedaf32511782de9176ccbdbd Modified Files -------------- src/backend/postmaster/bgworker.c | 23 +++++++++++++++-------- src/backend/postmaster/postmaster.c | 9 +++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Report failure to start a background worker. @ 2017-12-06 14:11 Robert Haas <rhaas@postgresql.org> 0 siblings, 0 replies; 5+ messages in thread From: Robert Haas @ 2017-12-06 14:11 UTC (permalink / raw) To: pgsql-committers Report failure to start a background worker. When a worker is flagged as BGW_NEVER_RESTART and we fail to start it, or if it is not marked BGW_NEVER_RESTART but is terminated before startup succeeds, what BgwHandleStatus should be reported? The previous code really hadn't considered this possibility (as indicated by the comments which ignore it completely) and would typically return BGWH_NOT_YET_STARTED, but that's not a good answer, because then there's no way for code using GetBackgroundWorkerPid() to tell the difference between a worker that has not started but will start later and a worker that has not started and will never be started. So, when this case happens, return BGWH_STOPPED instead. Update the comments to reflect this. The preceding fix by itself is insufficient to fix the problem, because the old code also didn't send a notification to the process identified in bgw_notify_pid when startup failed. That might've been technically correct under the theory that the status of the worker was BGWH_NOT_YET_STARTED, because the status would indeed not change when the worker failed to start, but now that we're more usefully reporting BGWH_STOPPED, a notification is needed. Without these fixes, code which starts background workers and then uses the recommended APIs to wait for those background workers to start would hang indefinitely if the postmaster failed to fork a worker. Amit Kapila and Robert Haas Discussion: http://postgr.es/m/CAA4eK1KDfKkvrjxsKJi3WPyceVi3dH1VCkbTJji2fuwKuB=3uw@mail.gmail.com Branch ------ REL9_4_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/facd94e72f27992ea5488aa59364778d54f978b8 Modified Files -------------- src/backend/postmaster/bgworker.c | 23 +++++++++++++++-------- src/backend/postmaster/postmaster.c | 9 +++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Report failure to start a background worker. @ 2017-12-06 14:11 Robert Haas <rhaas@postgresql.org> 0 siblings, 0 replies; 5+ messages in thread From: Robert Haas @ 2017-12-06 14:11 UTC (permalink / raw) To: pgsql-committers Report failure to start a background worker. When a worker is flagged as BGW_NEVER_RESTART and we fail to start it, or if it is not marked BGW_NEVER_RESTART but is terminated before startup succeeds, what BgwHandleStatus should be reported? The previous code really hadn't considered this possibility (as indicated by the comments which ignore it completely) and would typically return BGWH_NOT_YET_STARTED, but that's not a good answer, because then there's no way for code using GetBackgroundWorkerPid() to tell the difference between a worker that has not started but will start later and a worker that has not started and will never be started. So, when this case happens, return BGWH_STOPPED instead. Update the comments to reflect this. The preceding fix by itself is insufficient to fix the problem, because the old code also didn't send a notification to the process identified in bgw_notify_pid when startup failed. That might've been technically correct under the theory that the status of the worker was BGWH_NOT_YET_STARTED, because the status would indeed not change when the worker failed to start, but now that we're more usefully reporting BGWH_STOPPED, a notification is needed. Without these fixes, code which starts background workers and then uses the recommended APIs to wait for those background workers to start would hang indefinitely if the postmaster failed to fork a worker. Amit Kapila and Robert Haas Discussion: http://postgr.es/m/CAA4eK1KDfKkvrjxsKJi3WPyceVi3dH1VCkbTJji2fuwKuB=3uw@mail.gmail.com Branch ------ REL9_5_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/0426a77ce465306e8a9bed441090c6941222e2ba Modified Files -------------- src/backend/postmaster/bgworker.c | 23 +++++++++++++++-------- src/backend/postmaster/postmaster.c | 9 +++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Report failure to start a background worker. @ 2017-12-06 14:11 Robert Haas <rhaas@postgresql.org> 0 siblings, 0 replies; 5+ messages in thread From: Robert Haas @ 2017-12-06 14:11 UTC (permalink / raw) To: pgsql-committers Report failure to start a background worker. When a worker is flagged as BGW_NEVER_RESTART and we fail to start it, or if it is not marked BGW_NEVER_RESTART but is terminated before startup succeeds, what BgwHandleStatus should be reported? The previous code really hadn't considered this possibility (as indicated by the comments which ignore it completely) and would typically return BGWH_NOT_YET_STARTED, but that's not a good answer, because then there's no way for code using GetBackgroundWorkerPid() to tell the difference between a worker that has not started but will start later and a worker that has not started and will never be started. So, when this case happens, return BGWH_STOPPED instead. Update the comments to reflect this. The preceding fix by itself is insufficient to fix the problem, because the old code also didn't send a notification to the process identified in bgw_notify_pid when startup failed. That might've been technically correct under the theory that the status of the worker was BGWH_NOT_YET_STARTED, because the status would indeed not change when the worker failed to start, but now that we're more usefully reporting BGWH_STOPPED, a notification is needed. Without these fixes, code which starts background workers and then uses the recommended APIs to wait for those background workers to start would hang indefinitely if the postmaster failed to fork a worker. Amit Kapila and Robert Haas Discussion: http://postgr.es/m/CAA4eK1KDfKkvrjxsKJi3WPyceVi3dH1VCkbTJji2fuwKuB=3uw@mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/28724fd90d2f85a0573a8107b48abad062a86d83 Modified Files -------------- src/backend/postmaster/bgworker.c | 23 +++++++++++++++-------- src/backend/postmaster/postmaster.c | 9 +++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Report failure to start a background worker. @ 2017-12-06 14:11 Robert Haas <rhaas@postgresql.org> 0 siblings, 0 replies; 5+ messages in thread From: Robert Haas @ 2017-12-06 14:11 UTC (permalink / raw) To: pgsql-committers Report failure to start a background worker. When a worker is flagged as BGW_NEVER_RESTART and we fail to start it, or if it is not marked BGW_NEVER_RESTART but is terminated before startup succeeds, what BgwHandleStatus should be reported? The previous code really hadn't considered this possibility (as indicated by the comments which ignore it completely) and would typically return BGWH_NOT_YET_STARTED, but that's not a good answer, because then there's no way for code using GetBackgroundWorkerPid() to tell the difference between a worker that has not started but will start later and a worker that has not started and will never be started. So, when this case happens, return BGWH_STOPPED instead. Update the comments to reflect this. The preceding fix by itself is insufficient to fix the problem, because the old code also didn't send a notification to the process identified in bgw_notify_pid when startup failed. That might've been technically correct under the theory that the status of the worker was BGWH_NOT_YET_STARTED, because the status would indeed not change when the worker failed to start, but now that we're more usefully reporting BGWH_STOPPED, a notification is needed. Without these fixes, code which starts background workers and then uses the recommended APIs to wait for those background workers to start would hang indefinitely if the postmaster failed to fork a worker. Amit Kapila and Robert Haas Discussion: http://postgr.es/m/CAA4eK1KDfKkvrjxsKJi3WPyceVi3dH1VCkbTJji2fuwKuB=3uw@mail.gmail.com Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/a8ef4e81e6f2b7ab77aa57b986742feba57d9d86 Modified Files -------------- src/backend/postmaster/bgworker.c | 23 +++++++++++++++-------- src/backend/postmaster/postmaster.c | 9 +++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2017-12-06 14:11 UTC | newest] Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2017-12-06 14:11 pgsql: Report failure to start a background worker. Robert Haas <rhaas@postgresql.org> 2017-12-06 14:11 pgsql: Report failure to start a background worker. Robert Haas <rhaas@postgresql.org> 2017-12-06 14:11 pgsql: Report failure to start a background worker. Robert Haas <rhaas@postgresql.org> 2017-12-06 14:11 pgsql: Report failure to start a background worker. Robert Haas <rhaas@postgresql.org> 2017-12-06 14:11 pgsql: Report failure to start a background worker. 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