test(qwp): fix port collision flake in walk tracker test - #103
Open
bluestreak01 wants to merge 1 commit into
Open
bluestreak01 wants to merge 1 commit into
bluestreak01 wants to merge 1 commit into
Conversation
testWalk_TransportFailureContinuesWalk failed in CI with "duplicate addr entry: localhost:46809" thrown by ConfigView.parseEntry(). The test called TestPorts.findUnusedPort() to pick a refused port. That helper binds port 0, closes the probe socket and returns the number. The test then created a TestWebSocketServer, whose constructor binds its own port 0. Nothing held the probe port in between, so the kernel could hand the same port to the server. Both addr entries then pointed at the same endpoint, and QwpQueryClient.fromConfig() rejected the config before the walk ever ran. The test now creates the server first and probes for the dead port while the server's listener holds its port. The kernel never assigns a port that a live listener owns, so the two ports always differ. The remaining exposure - another process taking the dead port before the client connects - matches every other pre-selected-port test in the suite.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test-only change. It fixes an intermittent failure of
QwpQueryClientWalkTrackerTest.testWalk_TransportFailureContinuesWalk.Failure
The test failed on questdb/questdb#7680 CI, job "SelfHosted Other tests (B) on linux-x64-zfs" (build 274943):
Root cause
The test builds
addr=localhost:<portDead>,localhost:<portOk>:TestPorts.findUnusedPort()suppliesportDead: it binds port 0, closes the probe socket, and returns the number. Nothing holds the port afterwards.new TestWebSocketServer(NOOP_HANDLER)then binds its own port 0 forportOk, and the kernel may hand it the port the probe just released.In the failing run both values came out as 46809.
ConfigView.parseEntry()correctly rejects the duplicate(host, port)pair, sofromConfig()threw before the client attempted any connection. The walk-tracker logic the test targets never ran, and the product code behaved as specified.The
TestPorts.findUnusedPorts(int)javadoc already describes the same race for two back-to-backfindUnusedPort()calls. This test pairs one probe with a server's ownbind(0), which that helper does not cover.Change
The test now creates the server first and probes for
portDeadwhile the server's listener holdsportOk.TestWebSocketServerbinds its listener in the constructor and keeps it untilclose(), and the kernel never assigns abind(0)port that a live socket on the same address holds, so the two ports cannot collide.Tradeoff: the test keeps the suite's existing bind-close-reuse exposure, where another process could bind
portDeadbetween the probe and the client's connect attempt. Every other pre-selected-port test in the suite accepts the same exposure. The change touches no production code and no shared test helper.Test plan
mvn -pl core test -Dtest=QwpQueryClientWalkTrackerTest: 12/12 green on JDK 25, both on0b9b5766(the commit questdb master pins) and on this branch (mainplus the fix).