sidekiq: terminate child processes at shutdown
What does this MR do?
Sidekiq jobs frequently spawn long-lived child processes to do work. In some circumstances, these can be reparented to init when sidekiq is terminated, leading to duplication of work and strange concurrency problems.
This commit changes sidekiq so that, if run as a process group leader, it will forward INT
and TERM
signals to the whole process group. If the memory killer is active, it will also use the process group when resorting to kill -9
to shut down.
These changes mean that a naive kill <pid-of-sidekiq>
will now do the right thing, killing any child processes spawned by sidekiq, as long as the process supervisor placed it in its own process group.
If sidekiq isn't a process group leader, this new code is skipped.
What are the relevant issue numbers?
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
Documentation created/updated via this MR -
Documentation reviewed by technical writer or follow-up review issue created -
Tests added for this feature/bug -
Tested in all supported browsers -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides -
Conforms to the database guides -
Link to e2e tests MR added if this MR has Requires e2e tests label. See the Test Planning Process. -
Security reports checked/validated by reviewer
Related to #40396 (closed)