Skip to content

Conversation

@google-labs-jules
Copy link
Contributor

This PR addresses critical concurrency issues in the configuration and logging subsystems.

Configuration Fixes

  • Race Condition: The Config struct in internal/config/config.go was vulnerable to data races where fields were read while being written (e.g., by the orchestrator).
  • Solution: Added a sync.RWMutex to the Config struct. All method implementations of the Interface (Getters and Setters) now strictly use RLock() and Lock() respectively to ensure thread safety.

Logger Fixes

  • Split-Brain Logging: Previously, if GetLogger() was called before Initialize(), the caller received a fallback logger and would hold onto it indefinitely, ignoring the subsequent initialization.
  • Solution: Implemented the Proxy Pattern. GetLogger() now returns a stable singleton proxyLogger backed by a proxyCore. This core delegates dynamically to the underlying globalLogger, ensuring that when Initialize() runs, all existing references effectively "hot-swap" to the new configuration.
  • Unsafe Test Reset: The ResetForTest function was overwriting a sync.Once value, which is unsafe.
  • Solution: Replaced sync.Once with atomic.Pointer[sync.Once], allowing safe and atomic resetting of initialization state for tests.

Verification

  • Added/Updated unit tests in pkg/observability to verify the proxy behavior and initialization logic.
  • Ran existing tests for internal/config (failures unrelated to these changes were noted but out of scope).

PR created automatically by Jules for task 3017510955809941058 started by @xkilldash9x

- 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`.
@google-labs-jules
Copy link
Contributor Author

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!


For security, I will only act on instructions from the user who triggered this task.

New to Jules? Learn more at jules.google/docs.

@xkilldash9x xkilldash9x marked this pull request as ready for review December 30, 2025 16:23
@xkilldash9x xkilldash9x merged commit c19150f into main Dec 30, 2025
4 of 5 checks passed
@xkilldash9x xkilldash9x deleted the fix-config-race-logger-proxy-3017510955809941058 branch December 30, 2025 16:24
xkilldash9x added a commit that referenced this pull request Jan 6, 2026
…3017510955809941058

Fix Config Race Condition and Logger Split-Brain
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.

1 participant