Add a new API updateGlobalConfig#210
Conversation
greensky00
commented
Jan 8, 2026
- It will update global config (such as sleep time and throttling limits) on-the-fly, without restarting the singleton instance.
* It will update global config (such as sleep time and throttling limits) on-the-fly, without restarting the singleton instance.
There was a problem hiding this comment.
Pull request overview
This PR adds a new API updateGlobalConfig that enables dynamic updates to global configuration settings (such as sleep times and throttling limits) without requiring a restart of the singleton instance.
Key changes:
- Added
updateGlobalConfig()method to the public API (DBclass andjunglenamespace) - Refactored worker management to support on-the-fly configuration updates via new virtual method
applyNewGlobalConfig() - Renamed
sleepDuration_mstosleepDurationMsfor consistency across the codebase
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| include/libjungle/jungle.h | Added public API declarations for updateGlobalConfig() |
| src/jungle.cc | Implemented DB::updateGlobalConfig() to delegate to DBMgr |
| src/db_mgr.h, src/db_mgr.cc | Added updateGlobalConfig() to propagate config changes to workers |
| src/worker_mgr.h, src/worker_mgr.cc | Refactored worker loop to check for and apply new configs; renamed sleep duration field |
| src/flusher.h, src/flusher.cc | Implemented applyNewGlobalConfig() for Flusher worker |
| src/compactor.h, src/compactor.cc | Implemented applyNewGlobalConfig() for Compactor worker |
| src/log_reclaimer.h, src/log_reclaimer.cc | Implemented applyNewGlobalConfig() for LogReclaimer worker |
| src/cmd_handler.h, src/cmd_handler.cc | Implemented applyNewGlobalConfig() for CmdHandler worker |
| tests/stress/flush_stress_test.cc | Added stress test validating dynamic config updates during runtime |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * @return OK on success. | ||
| */ | ||
| static inline Status updateGlobalConfig(const GlobalConfig& new_config) { | ||
| (void)updateGlobalConfig; |
There was a problem hiding this comment.
This line suppresses the unused function warning for the wrong function. It should suppress the warning for the parameter new_config instead, similar to how the init function handles its parameter with (void)init;. The correct statement should be (void)new_config;.
| (void)updateGlobalConfig; | |
| (void)new_config; |
src/worker_mgr.cc
Outdated
| void WorkerBase::applyNewGlobalConfig(const GlobalConfig& g_config) { | ||
| gConfig = g_config; | ||
| WorkerOptions options; | ||
| options.sleepDurationMs = gConfig.flusherSleepDuration_ms; | ||
| options.worker = this; | ||
| curOptions = options; | ||
| _log_info(DBMgr::getWithoutInit()->getLogger(), | ||
| "worker %s applied new global config", workerName.c_str()); | ||
| } |
There was a problem hiding this comment.
The base implementation assumes all workers use flusherSleepDuration_ms, but this is not appropriate for all worker types. Since each worker subclass has its own applyNewGlobalConfig() implementation that sets the correct sleep duration, this base implementation should not set sleepDurationMs at all, or it should be removed entirely if not needed as a default implementation.