Skip to content

RFE: IdleTerminationTimeout directive to prefork/worker/event MPMs. - #726

Open
notroj wants to merge 11 commits into
apache:trunkfrom
notroj:idle-termination-tests
Open

RFE: IdleTerminationTimeout directive to prefork/worker/event MPMs.#726
notroj wants to merge 11 commits into
apache:trunkfrom
notroj:idle-termination-tests

Conversation

@notroj

@notroj notroj commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

Builds on #529 by Alex/AT, which adds an IdleTerminationTimeout directive to
the prefork, worker and event MPMs: the server terminates itself once idle, so
that a socket-activated instance hands its listening socket back to the service
manager rather than sitting there.

The first commit is that patch unchanged. The rest are a test suite and fixes
for what it turned up:

  • A server serving one request a second was counted idle at every sample and
    terminated. Idleness is now "nothing has happened since the last check".
  • Connections held open by the event MPM occupy no worker, and were dropped.
    The open connection count is now published where it changes rather than only
    when a timeout queue expires, which also fixes ConnsTotal reading zero in
    mod_status with connections open.
  • The countdown ran in maintenance cycles rather than seconds, so it expired
    early when children exited, and num_buckets times too fast with more than
    one listener bucket. It is now timed from a timestamp.
  • The value was parsed with atoi(), so anything unparseable meant zero, that
    is, terminate as soon as idle.
  • The timeout was not reset in pre_config, so it survived a reload which no
    longer configured it.
  • The new shutdown message reused the SIGTERM message's APLOGNO.

test/modules/core/test_007_idle_termination.py covers all of the above, and
skips on MPMs which do not implement the directive. CI gains a prefork run of
the pytest suites, since nothing set MPM before.

Not done: documentation in docs/manual/. The shutdown is also still
ungraceful, which is safe now that it only fires with no connections open, but
that should be said in the docs.

Only the event MPM was exercised locally; prefork is covered by the new CI job.

🤖 Generated with Claude Code

@notroj
notroj force-pushed the idle-termination-tests branch 3 times, most recently from 1b574fa to 6e7ca72 Compare August 30, 2026 08:02
notroj and others added 11 commits August 30, 2026 11:08
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
  packages below it are collected only on the platform they are named
  for.  [skip ci]

* test/modules/arch/linux/README: Note it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
  server/mpm/worker/worker.c: Add IdleTerminationTimeout, which shuts
  the server down once all workers have been idle for that many
  seconds.

* changes-entries/idle-termination-timeout.txt: Added.

Submitted by: Alex/AT <85214814+AlexAT users.noreply.github.com>
Github: closes apache#529
  server/mpm/worker/worker.c (set_idle_termination_timeout): Reject an
  IdleTerminationTimeout which is not a non-negative number of seconds,
  rather than letting atoi() read it as zero.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
  server/mpm/worker/worker.c (*_pre_config): Reset
  idle_termination_timeout with the other tunables, so that a reload
  which no longer configures it stops terminating the server.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
  connection counts on every pass, not only when a timeout queue
  expires.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
  decrement_connection_count, process_socket): Publish the open
  connection count where it changes.

* server/mpm/event/event.c, server/mpm/prefork/prefork.c,
  server/mpm/worker/worker.c (server_is_idle,
  perform_idle_server_maintenance): Base IdleTerminationTimeout on
  whether anything has happened since the last check, timed from a
  timestamp rather than counted in maintenance cycles.  A server under
  steady traffic terminated, connections held open by an async MPM were
  dropped, and the timeout expired early.

* .github/workflows/linux.yml: Run the pytest suites under prefork too.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
  server/mpm/worker/worker.c: Give the idle timeout shutdown message its
  own APLOGNO.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
  server/mpm/worker/worker.c: Code style tweaks only, no functional
  change.

[skip ci]

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
  --max-time.  A server which accepts a connection and then never
  answers it hung the whole test run rather than failing it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@notroj
notroj force-pushed the idle-termination-tests branch from 6e7ca72 to df4ef3f Compare August 30, 2026 10:22
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.

2 participants