Skip to content

Investigate Oban queue draining

In the past I've seen Pleroma take an unexpectedly long time to shutdown after receiving a SIGTERM. My memory of when it started seems to align with the same time we added Oban to the project. I believe the issue is rooted in the way Oban tries to drain the queue before shutdown. The behavior I experienced feels like it would match the documented shutdown grace period of 15 seconds: https://github.com/sorentwo/oban/blob/v1.0.0/lib/oban.ex#L123

Docs about it can be found here: https://hexdocs.pm/oban/readme.html#features

After a brief discussion with @lambadalambda we want to investigate this. I believe it's possible we are doing the wrong thing during shutdown. We should not be accepting new jobs into the queue after shutdown has started. This would prevent the queue from continuing to fill on a server with a slower CPU and/or database, and delaying the shutdown 15 seconds as a result.