Skip to content

Shared dict state file #915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 22, 2025
Merged

Shared dict state file #915

merged 6 commits into from
May 22, 2025

Conversation

xeioex
Copy link
Contributor

@xeioex xeioex commented May 21, 2025

Modules: added state file for a shared dictionary.

A new optional state parameter is added for js_shared_dict_zone
directive. state parameter specifies a file that keeps the current state
of the shared dict in the JSON format and makes it persistent
across nginx restarts.

This closes #709 feature request on Github.

@xeioex xeioex requested a review from VadimZhestikov May 21, 2025 01:36
A new optional state parameter is added for js_shared_dict_zone
directive. state parameter specifies a file that keeps the current state
of the shared dict in the JSON format and makes it persistent
across nginx restarts.

This closes nginx#709 feature request on Github.
@xeioex xeioex force-pushed the shared_dict_state_file branch from 3c4a405 to 75371c1 Compare May 21, 2025 17:06
Copy link
Contributor

@VadimZhestikov VadimZhestikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@xeioex xeioex requested a review from Copilot May 22, 2025 22:38
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds persistent state file support for js_shared_dict_zone by introducing a new optional state parameter and ensuring shared dictionary data is serialized to and from a JSON file across NGINX restarts.

  • Introduces a conditional guard in njs_chb_destroy to avoid calling a null free callback.
  • Adds ngx_js_dict_init_worker initialization in both HTTP and stream modules, alongside refactoring periodic init into separate functions.
  • Includes new tests (*_state.t) to verify state file persistence and removes obsolete engine exports from existing NJS test files.

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/njs_chb.c Guarded the free callback in chain destruction when chain->free is null
nginx/ngx_js_shared_dict.h Declared ngx_js_dict_init_worker for shared dict worker init
nginx/ngx_js.h Moved fetch/shared_dict includes and added NGX_CHB_CTX_INIT macro
nginx/ngx_stream_js_module.c Refactored worker init to call periodic and dict init separately
nginx/ngx_http_js_module.c Mirrored stream changes for HTTP module worker init
nginx/t/stream_js_shared_dict_state.t New stream tests for shared dict state file persistence
nginx/t/js_shared_dict_state.t New HTTP tests for shared dict state file persistence
nginx/t/stream_js_shared_dict.t Removed unused engine exports
nginx/t/stream_js_periodic_fetch.t Removed unused engine exports
nginx/t/stream_js_fetch_init.t Removed unused engine exports
nginx/t/stream_js_fetch_https.t Removed unused engine exports
nginx/t/stream_js_fetch.t Removed unused engine exports
nginx/t/js_shared_dict.t Removed unused engine exports
nginx/t/js_periodic_fetch.t Removed unused engine exports
nginx/t/js_fetch_verify.t Removed unused engine exports
nginx/t/js_fetch_timeout.t Removed unused engine exports
nginx/t/js_fetch_resolver.t Removed unused engine exports
nginx/t/js_fetch_objects.t Removed unused engine exports
nginx/t/js_fetch_https.t Removed unused engine exports
nginx/t/js_fetch.t Removed unused engine exports

@xeioex xeioex merged commit eca0362 into nginx:master May 22, 2025
1 check passed
@xeioex xeioex deleted the shared_dict_state_file branch May 22, 2025 23:54
@xeioex xeioex added this to the 0.9.1 milestone May 23, 2025
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.

Add support for statefiles to js_shared_dict_zone.
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy