]> git.kaiwu.me - njs.git/commit
Modules: track shared dict state changes per worker
authorDmitry Volyntsev <xeioex@nginx.com>
Sat, 10 Oct 2026 01:32:25 +0000 (18:32 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Thu, 15 Oct 2026 01:49:05 +0000 (18:49 -0700)
commitac110b37fd7abb564822652c9e47d7a7ee0a6db6
tree2b5f47046d06b6d42546cbabff683270e842ac66
parent45db3a190876c0ca49a427641ac4ffe16b7e7ef9
Modules: track shared dict state changes per worker

With frequent changes to a shared dict zone using state=, old workers
can remain in shutting down after a configuration reload and continue
consuming resources even though their changes have already been included
in another worker's snapshot.  The shared dirty flag cannot distinguish
those changes from subsequent changes made by new workers, so old
workers can keep rearming their save timers while competing for writes.

Replace the shared dirty flag with a write_id counter and record its
value locally in each worker on mutation.  Advance the shared counter
after preparing a snapshot so workers whose changes are covered can
stop retrying regardless of subsequent mutations.  On I/O failure, the
writer records the advanced counter locally to retain responsibility
for retrying the save.
nginx/ngx_js_shared_dict.c