Repository navigation
test: isolate logservice watermark and gossip fixtures - #28556
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Force review conclusion: COMMENT (own PR; APPROVE/REQUEST_CHANGES are not allowed). Exact head: 18fe840
Confirmed delivery blocker
P2 — The exact-head static-check gate fails because the new fmt.Errorf calls in pkg/logservice/test_utils.go:70 and :75 are in a non-*_test.go file. static-check-analysis / err-check rejects them with “Use moerr instead” (CI job 102694195002).
Please use policy-compliant error construction while preserving errors.Is(err, syscall.EMFILE), then rerun the actual static-check target.
Non-blocking risks / test gaps
test_utils.go:78releases socket probes before startup, leaving a probe-to-bind race.test_ports_test.go:25does not directly cover concurrent allocation uniqueness, repeated allocation, or failed-allocation reuse.- Cleanup/shutdown is synchronous and blocked shutdown was not fault-tested.
- Dependent consumers, local Go UT/race/vet, live cluster/SQL tests, fault injection, benchmarks, and compatibility testing were not independently run.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed all changed hunks and the allocator/fixture ownership paths. The head advanced during review from a6939e273010afddb0b243f129e6126d68ebb44f to 374df5b2e79a0794ebe71e7f04d892c9c97d2920; I checked the intervening logservice delta and its interaction with this PR. Current base is 3132f576ece54349e6f0c61b9c2e3b9c6ec19ce7. COMMENT only for this self-authored PR. No concrete blocker found.
The exact watermark/recovery-state assertions remain intact. Stopping and joining the checker before initialization removes a competing state owner. The merged #28554 now routes these cases through a manual fixture with DisableWorkers=true; the additional Stop calls are harmless and the normal ticker-enabled fixture remains separate. Each test owns a fresh store, so this does not disable a checker for a later case.
| Unhappy-path contract | Review result |
|---|---|
| Q1 cleanup | TCP probes use deferred Close, including UDP-bind failure; successful UDP probes close before return. Gossip cleanup is installed before service creation and joins every already-created service after failure. |
| Q2 concurrency | The allocator mutex covers uniqueness checks, probes and insertion; only EADDRINUSE retries. EMFILE and other failures propagate immediately, with unlock on every return. Checker Stop cancels and joins before the test writes its baseline. |
| Q3 bounds | Candidate attempts are capped at 128; the process-local reservation map is bounded by the finite port range. Topology stays at 24 nodes (six in short mode), with unchanged replica-addition and restart oracles. |
Wildcard and loopback TCP4/UDP4 probes match the fixture's IPv4 bind addresses and remove the old Linux-only TCP snapshot dependency. No architecture-specific operation was introduced; macOS/arm64 execution is reported, while Linux execution remains a CI claim to establish. The tests cover occupancy, retry exhaustion, immediate resource errors and TCP release after UDP failure. Port probing is deliberately not atomic reservation against other processes; the documented bind-before-service-start race remains, but is not newly claimed to be eliminated.
No production service behavior or public SQL contract is changed, so no new feature-design or BVT requirement applies. The extra bounded bind/close operations trade small fixture setup work for actual socket availability checks; no measured Linux performance improvement is claimed. git diff --check passed for the initially reviewed range. The PR reports focused repeated race and owning-package race validation on macOS; those runs predate the just-observed main merge, so I do not present them as fresh execution of the merged head. I did not wait for CI or start duplicate long tests.
…28556) ## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#28419 ## What this PR does / why we need it: `TestRestoreIDWatermarksRejectsLateLogServiceRecovery` expects a rejected recovery to leave the exact ID watermark unchanged. Its background HAKeeper checker could independently preallocate 10240 IDs: CI observed `0x4280a` instead of `0x4000a`. `TestSetInitialClusterInfo` showed the same failure during package race validation. Stop and join the checker before initializing the state these tests explicitly drive. Retain the exact watermark, error and recovery-state assertions. `TestGossipInSimulatedCluster` used fixed ports starting at 26000. Docker listeners occupied several of those ports locally, causing invalid gossip protocol responses and a roughly 52-second convergence failure. Allocate each service/Raft/gossip port and derive seeds from the allocated gossip ports. Preserve the 24-node topology, replica-addition and restart assertions, plus the existing short-suite topology. Harden the shared test allocator: * Probe TCP and UDP on both wildcard and loopback addresses. macOS can allow a wildcard TCP bind beside an existing specific-address listener, so wildcard-only probing is insufficient. * Close all probe sockets, including the TCP socket when UDP binding fails. Remove obsolete OS-specific port-snapshot helpers. * Retry only address-in-use errors, with a maximum of 128 candidate attempts. Other failures, including descriptor exhaustion, immediately propagate their cause to the fixture instead of spinning until the whole test times out. * Register cluster cleanup before the creation loop, so a partial-start failure closes services already created. The probes do not atomically reserve a port until service startup. Another process can still bind during that interval; the fixture must fail clearly and clean up. The allocator remains scoped to test utilities, with no production service-path changes. Validation on macOS/arm64: * Each original failing test passes `-race -count=20` after the final review fixes. * `TestSetInitialClusterInfo` also passes `-race -count=20`. * New focused race-tested cases cover available/occupied ports, bounded exhaustion, immediate `EMFILE` propagation, TCP/UDP occupancy and TCP cleanup after UDP probe failure. * Incremental `golangci-lint` for `./pkg/logservice/...`: `0 issues`. * Final owning-package `-race -count=1` run passes (115.773 seconds). Linux execution is left to CI; no local Linux execution is claimed.
…28556) ## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#28419 ## What this PR does / why we need it: `TestRestoreIDWatermarksRejectsLateLogServiceRecovery` expects a rejected recovery to leave the exact ID watermark unchanged. Its background HAKeeper checker could independently preallocate 10240 IDs: CI observed `0x4280a` instead of `0x4000a`. `TestSetInitialClusterInfo` showed the same failure during package race validation. Stop and join the checker before initializing the state these tests explicitly drive. Retain the exact watermark, error and recovery-state assertions. `TestGossipInSimulatedCluster` used fixed ports starting at 26000. Docker listeners occupied several of those ports locally, causing invalid gossip protocol responses and a roughly 52-second convergence failure. Allocate each service/Raft/gossip port and derive seeds from the allocated gossip ports. Preserve the 24-node topology, replica-addition and restart assertions, plus the existing short-suite topology. Harden the shared test allocator: * Probe TCP and UDP on both wildcard and loopback addresses. macOS can allow a wildcard TCP bind beside an existing specific-address listener, so wildcard-only probing is insufficient. * Close all probe sockets, including the TCP socket when UDP binding fails. Remove obsolete OS-specific port-snapshot helpers. * Retry only address-in-use errors, with a maximum of 128 candidate attempts. Other failures, including descriptor exhaustion, immediately propagate their cause to the fixture instead of spinning until the whole test times out. * Register cluster cleanup before the creation loop, so a partial-start failure closes services already created. The probes do not atomically reserve a port until service startup. Another process can still bind during that interval; the fixture must fail clearly and clean up. The allocator remains scoped to test utilities, with no production service-path changes. Validation on macOS/arm64: * Each original failing test passes `-race -count=20` after the final review fixes. * `TestSetInitialClusterInfo` also passes `-race -count=20`. * New focused race-tested cases cover available/occupied ports, bounded exhaustion, immediate `EMFILE` propagation, TCP/UDP occupancy and TCP cleanup after UDP probe failure. * Incremental `golangci-lint` for `./pkg/logservice/...`: `0 issues`. * Final owning-package `-race -count=1` run passes (115.773 seconds). Linux execution is left to CI; no local Linux execution is claimed.
…28556) ## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#28419 ## What this PR does / why we need it: `TestRestoreIDWatermarksRejectsLateLogServiceRecovery` expects a rejected recovery to leave the exact ID watermark unchanged. Its background HAKeeper checker could independently preallocate 10240 IDs: CI observed `0x4280a` instead of `0x4000a`. `TestSetInitialClusterInfo` showed the same failure during package race validation. Stop and join the checker before initializing the state these tests explicitly drive. Retain the exact watermark, error and recovery-state assertions. `TestGossipInSimulatedCluster` used fixed ports starting at 26000. Docker listeners occupied several of those ports locally, causing invalid gossip protocol responses and a roughly 52-second convergence failure. Allocate each service/Raft/gossip port and derive seeds from the allocated gossip ports. Preserve the 24-node topology, replica-addition and restart assertions, plus the existing short-suite topology. Harden the shared test allocator: * Probe TCP and UDP on both wildcard and loopback addresses. macOS can allow a wildcard TCP bind beside an existing specific-address listener, so wildcard-only probing is insufficient. * Close all probe sockets, including the TCP socket when UDP binding fails. Remove obsolete OS-specific port-snapshot helpers. * Retry only address-in-use errors, with a maximum of 128 candidate attempts. Other failures, including descriptor exhaustion, immediately propagate their cause to the fixture instead of spinning until the whole test times out. * Register cluster cleanup before the creation loop, so a partial-start failure closes services already created. The probes do not atomically reserve a port until service startup. Another process can still bind during that interval; the fixture must fail clearly and clean up. The allocator remains scoped to test utilities, with no production service-path changes. Validation on macOS/arm64: * Each original failing test passes `-race -count=20` after the final review fixes. * `TestSetInitialClusterInfo` also passes `-race -count=20`. * New focused race-tested cases cover available/occupied ports, bounded exhaustion, immediate `EMFILE` propagation, TCP/UDP occupancy and TCP cleanup after UDP probe failure. * Incremental `golangci-lint` for `./pkg/logservice/...`: `0 issues`. * Final owning-package `-race -count=1` run passes (115.773 seconds). Linux execution is left to CI; no local Linux execution is claimed.
What type of PR is this?
Which issue(s) this PR fixes:
issue #28419
What this PR does / why we need it:
TestRestoreIDWatermarksRejectsLateLogServiceRecoveryexpects a rejected recovery to leave the exact ID watermark unchanged. Its background HAKeeper checker could independently preallocate 10240 IDs: CI observed0x4280ainstead of0x4000a.TestSetInitialClusterInfoshowed the same failure during package race validation. Stop and join the checker before initializing the state these tests explicitly drive. Retain the exact watermark, error and recovery-state assertions.TestGossipInSimulatedClusterused fixed ports starting at 26000. Docker listeners occupied several of those ports locally, causing invalid gossip protocol responses and a roughly 52-second convergence failure. Allocate each service/Raft/gossip port and derive seeds from the allocated gossip ports. Preserve the 24-node topology, replica-addition and restart assertions, plus the existing short-suite topology.Harden the shared test allocator:
The probes do not atomically reserve a port until service startup. Another process can still bind during that interval; the fixture must fail clearly and clean up. The allocator remains scoped to test utilities, with no production service-path changes.
Validation on macOS/arm64:
-race -count=20after the final review fixes.TestSetInitialClusterInfoalso passes-race -count=20.EMFILEpropagation, TCP/UDP occupancy and TCP cleanup after UDP probe failure.golangci-lintfor./pkg/logservice/...:0 issues.-race -count=1run passes (115.773 seconds).Linux execution is left to CI; no local Linux execution is claimed.