Commit ddf2fc4
authored
fix: eliminate cfg.Logger data race in server()'s reload/shutdown path (#9581)
* fix: eliminate cfg.Logger data race in server()'s reload/shutdown path
Loader.New() aliases the *config.Server passed to it, so the watcher
goroutine's cfg.Logger reassignment on each config reload directly
mutates the same struct instance server()'s top-level select loop
reads from when logging shutdown/hook-error messages. The watcher
writes under cfgMu, but server() read cfg.Logger with no
synchronization at all, producing a genuine data race (confirmed via
the actual CI job log: write at configloader.go:91 vs. read at
server.go:112, and reproduced locally under linux/-race).
Fix: the loader publishes each new logger over a small "latest value"
channel as reloads happen. server() keeps its own local logger
reference and swaps it only upon receiving from that channel, so the
update is synchronized via channel send/receive instead of a shared,
unguarded field.
Signed-off-by: Muhammad Waqar <mwaqar@confluent.io>
* fix: simplify logger race fix to a mutex-guarded Loader.Logger() accessor
Per review feedback (github.com//pull/9581#issuecomment-5077942710):
drop the loggerUpdates channel and drain logic in favor of a simple
RLock-guarded Logger() getter on Loader, reusing the existing cfgMu
rather than introducing new synchronization.
Signed-off-by: Muhammad Waqar <mwaqar@confluent.io>
---------
Signed-off-by: Muhammad Waqar <mwaqar@confluent.io>1 parent 8e32174 commit ddf2fc4
3 files changed
Lines changed: 14 additions & 2 deletions
File tree
- internal
- cmd
- envoygateway/config/loader
- release-notes/current/bug_fixes
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
106 | 109 | | |
107 | 110 | | |
108 | 111 | | |
109 | 112 | | |
110 | 113 | | |
111 | 114 | | |
112 | | - | |
| 115 | + | |
113 | 116 | | |
114 | 117 | | |
115 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
145 | 153 | | |
146 | 154 | | |
147 | 155 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments