- Notifications
You must be signed in to change notification settings - Fork906
Commit533c6dc
authored
fix: remove error log when notification manager is already closed (#18264)
Closescoder/internal#677Resolves flakes such as:```$ go test -race -run "TestRunStopRace" github.com/coder/coder/v2/coderd/notifications -count=10000 -parallel $(nproc)--- FAIL: TestRunStopRace (0.00s) t.go:106: 2025-06-06 02:44:39.348 [debu] notifications-manager: notification manager started t.go:106: 2025-06-06 02:44:39.348 [debu] notifications-manager: graceful stop requested t.go:106: 2025-06-06 02:44:39.348 [debu] notifications-manager: notification manager stopped t.go:115: 2025-06-06 02:44:39.348 [erro] notifications-manager: notification manager stopped with error ... error= manager already closed: github.com/coder/coder/v2/coderd/notifications.(*Manager).loop /home/coder/coder/coderd/notifications/manager.go:166 *** slogtest: log detected at level ERROR; TEST FAILURE ***--- FAIL: TestRunStopRace (0.00s) t.go:106: 2025-06-06 02:44:41.632 [debu] notifications-manager: notification manager started t.go:106: 2025-06-06 02:44:41.632 [debu] notifications-manager: graceful stop requested t.go:106: 2025-06-06 02:44:41.632 [debu] notifications-manager: notification manager stopped t.go:115: 2025-06-06 02:44:41.633 [erro] notifications-manager: notification manager stopped with error ... error= manager already closed: github.com/coder/coder/v2/coderd/notifications.(*Manager).loop /home/coder/coder/coderd/notifications/manager.go:166 *** slogtest: log detected at level ERROR; TEST FAILURE ***FAILFAIL github.com/coder/coder/v2/coderd/notifications 6.847sFAIL```These error logs are caused as a result of the `Manager` `Run` start operation being asynchronous. In the flaking test case we immediately call `Stop` after `Run`. It's possible for `Stop` to be scheduled to completion before the goroutine spawned by `Run` calls `loop` and checks `closed`. If this happens, `loop` returns an error and produces the error log.We'll address this by replacing this specific error log with a warning log.```$ go test -run "TestRunStopRace" github.com/coder/coder/v2/coderd/notifications -count=10000 -parallel $(nproc)ok github.com/coder/coder/v2/coderd/notifications 1.294s$ go test -race github.com/coder/coder/v2/coderd/notifications -count=100 -parallel $(nproc)ok github.com/coder/coder/v2/coderd/notifications 26.525s```1 parent7c2fb66 commit533c6dc
1 file changed
+8
-2
lines changedLines changed: 8 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
135 | 135 |
| |
136 | 136 |
| |
137 | 137 |
| |
| 138 | + | |
| 139 | + | |
138 | 140 |
| |
139 | 141 |
| |
140 | 142 |
| |
| |||
146 | 148 |
| |
147 | 149 |
| |
148 | 150 |
| |
149 |
| - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
150 | 156 |
| |
151 | 157 |
| |
152 | 158 |
| |
| |||
163 | 169 |
| |
164 | 170 |
| |
165 | 171 |
| |
166 |
| - | |
| 172 | + | |
167 | 173 |
| |
168 | 174 |
| |
169 | 175 |
| |
|
0 commit comments
Comments
(0)