From 903748497809ea97011ff22a7aa09320d7c1b08c Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Fri, 9 Oct 2026 18:03:47 -0700 Subject: [PATCH] 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. --- nginx/ngx_js_shared_dict.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; } -- 2.47.3