Fix Config Race Condition and Logger Split-Brain#31
Conversation
- Added sync.RWMutex to Config struct and updated all getters/setters to use RLock/Lock to prevent concurrent read/write races. - Implemented Proxy Pattern for logger: introduced `proxyCore` and `proxyLogger` to ensure all logger references update dynamically when `Initialize()` is called, solving the "split-brain" logging issue. - Replaced `sync.Once` in logger with `atomic.Pointer[sync.Once]` to allow safe resetting in tests. - Updated logger tests to verify functionality instead of pointer equality for `GetLogger`.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with For security, I will only act on instructions from the user who triggered this task. New to Jules? Learn more at jules.google/docs. |
…3017510955809941058 Fix Config Race Condition and Logger Split-Brain
This PR addresses critical concurrency issues in the configuration and logging subsystems.
Configuration Fixes
Configstruct ininternal/config/config.gowas vulnerable to data races where fields were read while being written (e.g., by the orchestrator).sync.RWMutexto theConfigstruct. All method implementations of theInterface(Getters and Setters) now strictly useRLock()andLock()respectively to ensure thread safety.Logger Fixes
GetLogger()was called beforeInitialize(), the caller received a fallback logger and would hold onto it indefinitely, ignoring the subsequent initialization.GetLogger()now returns a stable singletonproxyLoggerbacked by aproxyCore. This core delegates dynamically to the underlyingglobalLogger, ensuring that whenInitialize()runs, all existing references effectively "hot-swap" to the new configuration.ResetForTestfunction was overwriting async.Oncevalue, which is unsafe.sync.Oncewithatomic.Pointer[sync.Once], allowing safe and atomic resetting of initialization state for tests.Verification
pkg/observabilityto verify the proxy behavior and initialization logic.internal/config(failures unrelated to these changes were noted but out of scope).PR created automatically by Jules for task 3017510955809941058 started by @xkilldash9x