From: Dmitry Volyntsev Date: Sat, 10 Oct 2026 01:03:47 +0000 (-0700) Subject: Modules: fix shared dict state save error ordering X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=903748497809ea97011ff22a7aa09320d7c1b08c;p=njs.git Modules: fix shared dict state save error ordering On save failure, writing is cleared before dirty is restored. Another worker can observe a clean, idle zone and stop retrying. If the failed writer is exiting, it also stops retrying and the changes remain unsaved. Set dirty first and add a memory barrier before clearing writing to publish the need for another save before releasing the writer. --- diff --git a/nginx/ngx_js_shared_dict.c b/nginx/ngx_js_shared_dict.c index 30de86bf..f324fd0c 100644 --- a/nginx/ngx_js_shared_dict.c +++ b/nginx/ngx_js_shared_dict.c @@ -2694,9 +2694,12 @@ error: ngx_destroy_pool(pool); + dict->sh->dirty = 1; + + ngx_memory_barrier(); + /* no lock required */ dict->sh->writing = 0; - dict->sh->dirty = 1; return NGX_ERROR; }