Commit f96349e
committed
Fix race with table init channel
The function to mark a table initialized wrongly closed the
channel immediately. This could cause an observer to be woken
up too early (before Commit() has finished) and get an uninitialized
snapshot.
Fix the timing issue by moving the closing into Commit(), next to
the normal watch channel closing. This way the initialized table has
been committed before the init watch channel closes.
This issue was detected by `pkg/k8s/statedb_test.go` in cilium/cilium:
statedb_test.go:263:
Error Trace: /home/runner/work/cilium/cilium/pkg/k8s/statedb_test.go:263
/home/runner/work/cilium/cilium/pkg/k8s/statedb_test.go:120
Error: Not equal:
expected: "obj1"
actual : "garbage"
Diff:
--- Expected
+++ Actual
@@ -1 +1 @@
-obj1
+garbage
Test: TestStateDBReflector/default
Signed-off-by: Jussi Maki <[email protected]>1 parent 574b83f commit f96349e
2 files changed
+14
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | 219 | | |
224 | 220 | | |
225 | 221 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
459 | 459 | | |
460 | 460 | | |
461 | 461 | | |
| 462 | + | |
| 463 | + | |
462 | 464 | | |
463 | 465 | | |
464 | 466 | | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
465 | 474 | | |
466 | 475 | | |
467 | 476 | | |
| |||
480 | 489 | | |
481 | 490 | | |
482 | 491 | | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
483 | 497 | | |
484 | 498 | | |
485 | 499 | | |
| |||
0 commit comments