feat: add worker_abort_timeout to delay SIGKILL during coredump - #1
Merged
Conversation
When a timed-out worker receives SIGABRT, a core dump may be in progress by the time the next heartbeat check runs. Sending SIGKILL at that point truncates the dump, making post-mortem analysis impossible. This change adds a new `--worker-abort-timeout` config option (defaults to 0 to preserve existing behaviour). When set to a positive value, the SIGKILL signal is only sent if (at least one condition fulfilled): * the process is not actively creating a core dump * the new timeout is exceeded
There was a problem hiding this comment.
Pull request overview
This PR introduces a new configuration option to prevent Gunicorn from prematurely sending SIGKILL to a worker that is still producing a core dump after a timeout-triggered SIGABRT, helping avoid truncated core files during post-mortem analysis.
Changes:
- Add
--worker-abort-timeout/worker_abort_timeoutsetting (default0) to optionally delaySIGKILLafterSIGABRT. - Track
worker.abort_timewhenSIGABRTis sent, and gateSIGKILLbased on elapsed time and a/proc/<pid>/statusCoreDumping:check. - Add arbiter tests covering abort time tracking and the new coredump wait behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
tests/test_arbiter.py |
Adds unit tests for abort timestamp tracking and delayed SIGKILL behavior under coredump conditions. |
gunicorn/config.py |
Adds the new worker_abort_timeout setting and CLI flag with user-facing documentation. |
gunicorn/arbiter.py |
Implements the coredump-aware SIGKILL delay and records abort_time when aborting a worker. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+612
to
+622
| @staticmethod | ||
| def _is_coredumping(pid: int) -> bool: | ||
| """Check whether a process is actively dumping core (Linux only, via /proc).""" | ||
| try: | ||
| with open(f"/proc/{pid}/status") as f: | ||
| for line in f: | ||
| if line.startswith("CoreDumping:"): | ||
| return line.split()[1] == "1" | ||
| except OSError: | ||
| pass | ||
| return False |
anmelle-slamcore
approved these changes
Jun 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a timed-out worker receives SIGABRT, a core dump may be in progress by the time the next heartbeat check runs. Sending SIGKILL at that point truncates the dump, making post-mortem analysis impossible.
This change adds a new
--worker-abort-timeoutconfig option (defaults to 0 to preserve existing behaviour). When set to a positive value, the SIGKILL signal is only sent if (at least one condition fulfilled):