Skip to content

feat: add worker_abort_timeout to delay SIGKILL during coredump - #1

Merged
loic-slamcore merged 1 commit into
masterfrom
3632-add-worker-abort-timeout
Jun 26, 2026
Merged

feat: add worker_abort_timeout to delay SIGKILL during coredump#1
loic-slamcore merged 1 commit into
masterfrom
3632-add-worker-abort-timeout

Conversation

@loic-slamcore

Copy link
Copy Markdown

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

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_timeout setting (default 0) to optionally delay SIGKILL after SIGABRT.
  • Track worker.abort_time when SIGABRT is sent, and gate SIGKILL based on elapsed time and a /proc/<pid>/status CoreDumping: 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 thread gunicorn/arbiter.py
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
@loic-slamcore
loic-slamcore merged commit 91db019 into master Jun 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants