Skip to content

Add lifecycle hook for worker stop event

Matthias Käppler requested to merge 370077-on-worker-stop into master

What does this MR do and why?

In #370077 (closed) we are looking to produce an object space dump whenever a worker is killed by memory-watchdog due to excessive memory use. In order to hook into the shut down procedure of a Puma worker, we need a new lifecycle hook, on_worker_stop, which is added here.

We need to solve this problem for both Puma and Sidekiq:

  • Puma: Puma already provides us with on_worker_shutdown, which can use to fire our own hooks. The benefit of this method is that it only fires after the worker is done processing requests.
  • Sidekiq: We can use on(:shutdown) for this. It is slightly less ideal in that this fires between the scheduler having shut down i.e. no more jobs being pulled in but before the worker might be done processing ongoing jobs. But I don't think we have another choice here.

This is a no-op for now since we are not using this hook anywhere yet.

NOTE: We also need to patch puma.rb in CNG and Omnibus and GDK, but this needs to happen after merging this:

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #370077 (closed)

Edited by Matthias Käppler

Merge request reports