Commit 86bb70f
Fix flaky PublicationManager relation tracker restart test (#4635)
Fixes #4606.
## Problem
The `PublicationManagerTest` "handles relation tracker restart" test is
flaky. It stops the `RelationTracker` (the supervisor then restarts it)
and relies on `assert_pub_tables` as a "wait for restart" barrier — but
it isn't one.
The relation is already in the publication and is **not** removed during
the restart, so `assert_pub_tables(ctx, [ctx.relation], …)` passes
immediately, potentially before the supervisor has restarted and
re-registered the process. The subsequent
`PublicationManager.remove_shape/2` call (→
`GenServer.call(name(stack_id), …)`) then races with a "no process"
exit.
## Fix
Wait for the `RelationTracker` to be re-registered, then for it to
finish restoring its filters from `ShapeStatus`, before issuing further
calls:
```elixir
assert wait_until(fn -> is_pid(GenServer.whereis(relation_tracker_name)) end, 2_000)
:ok = PublicationManager.wait_for_restore(ctx.stack_id, timeout: 2_000)
```
Rather than add a bespoke helper, this promotes the existing private
`wait_until` poller (previously in `shape_cache_test.exs`) into the
shared `Support.TestUtils` as `wait_until/2`, and migrates its original
call site to the shared version.
## Verification
15/15 seeded runs of the target test pass; the full
`publication_manager_test.exs` (26 tests) and the migrated
`shape_cache_test.exs` test are green. Test-only change, so no
changeset.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Oleksii Sholik <oleksii@sholik.dev>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent f245417 commit 86bb70f
4 files changed
Lines changed: 47 additions & 20 deletions
File tree
- .changeset
- packages/sync-service/test
- electric
- replication
- support
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
652 | 652 | | |
653 | 653 | | |
654 | 654 | | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
655 | 667 | | |
656 | 668 | | |
657 | 669 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
1338 | 1339 | | |
1339 | 1340 | | |
1340 | 1341 | | |
1341 | | - | |
1342 | | - | |
1343 | | - | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
1344 | 1346 | | |
1345 | 1347 | | |
1346 | 1348 | | |
| |||
1389 | 1391 | | |
1390 | 1392 | | |
1391 | 1393 | | |
1392 | | - | |
1393 | | - | |
1394 | | - | |
1395 | | - | |
1396 | | - | |
1397 | | - | |
1398 | | - | |
1399 | | - | |
1400 | | - | |
1401 | | - | |
1402 | | - | |
1403 | | - | |
1404 | | - | |
1405 | | - | |
1406 | | - | |
1407 | | - | |
1408 | 1394 | | |
1409 | 1395 | | |
1410 | 1396 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
141 | 165 | | |
142 | 166 | | |
143 | 167 | | |
| |||
0 commit comments