openresty / openresty/lua-nginx-module

privileged agent timers not fireing on shutdown

Open
#1,499 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
11.8k
Forks
2.1k
Avg merge
6h 1m
Merged PRs (30d)
6

Description

The privileged agents timers that are set to execute later will not execute upon nginx shutdown. ie. prematurely.

The fake watcher with the read->handler set to ngx_http_lua_abort_pending timers, is added although the handler is never executed.

By adding ngx_close_idle_connections within the privileged agents cycle inside the terminate/quit clause I did get the intended result.

I'm not certain that this is the correct solution or if it could have any unexpected consequences.

os/unix/ngx_process_cycle.c:

ngx_privileged_agent_process_cycle(ngx_cycle_t *cycle, void *data)
...

for ( ;; ) {

  if (ngx_terminate || ngx_quit) {
    ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting");
+  ngx_close_idle_connections(cycle);
    ngx_worker_process_exit(cycle);
  }
...

Any feedback regarding this, would be appreciated.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in os/unix/ngx_process_cycle.c at ngx_privileged_agent_process_cycle and trace how shutdown reaches ngx_worker_process_exit. Compare the privileged agent's timer and fake-watcher lifecycle with the proposed ngx_close_idle_connections call. Done means privileged agent timers execute as intended during nginx shutdown without introducing unexpected connection or process-exit effects.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, lua, nginx
Domain
backend, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.