Commit 27a4c30
authored
Buffered
Aims to fix another intermittent test failure:
https://github.com/riverqueue/river/actions/runs/24312716933/job/70985012980?pr=1205
--- FAIL: TestElector_WithNotifier (0.00s)
--- FAIL: TestElector_WithNotifier/RequestResignStress (20.41s)
elector_test.go:350: Generated postgres schema "leadership_2026_04_12t17_52_43_schema_04" with migrations [1 2 3 4 5 6] on line "main" in 229.626141ms [4 generated] [0 reused]
elector_test.go:352: Starting test_client_id
elector_test.go:375: Requesting leadership resign
elector_test.go:375: Requesting leadership resign
elector_test.go:375: Requesting leadership resign
elector_test.go:375: Requesting leadership resign
elector_test.go:375: Requesting leadership resign
test_signal.go:95: timed out waiting on test signal after 10s
test_signal.go:95: timed out waiting on test signal after 10s
riverdbtest.go:293: Checked in postgres schema "leadership_2026_04_12t17_52_43_schema_04"; 1 idle schema(s) [5 generated] [3 reused]
FAIL
FAIL github.com/riverqueue/river/internal/leadership 20.948s
The problem is that when `requestResignChan` is unbuffered, if
`keepLeadershipLoop` hasn't yet entered its `select`, then the `default`
statement on the `select` below will cause all senders (we have 5
competing senders in the `RequestResignStress` test case) to fall
through without sending anything:
select {
case <-ctx.Done():
case e.requestResignChan <- struct{}{}:
default:
// if context is not done and requestResignChan has an item in it
// already, do nothing
}
By making the channel buffered, we guarantee at least one sender gets a
message through, and we don't end up hanging the test.requestResignChan (#1207)1 parent 3f55dd5 commit 27a4c30
2 files changed
Lines changed: 28 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
143 | 145 | | |
144 | 146 | | |
145 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
347 | 372 | | |
348 | 373 | | |
349 | 374 | | |
| |||
0 commit comments