From 31ca2beeb7b8457c3dffacde982c55c1a293ab64 Mon Sep 17 00:00:00 2001 From: bluestreak Date: Sat, 3 Oct 2026 01:26:29 +0100 Subject: [PATCH] Fix port collision in walk tracker test 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. --- .../cutlass/qwp/client/QwpQueryClientWalkTrackerTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/test/java/io/questdb/client/test/cutlass/qwp/client/QwpQueryClientWalkTrackerTest.java b/core/src/test/java/io/questdb/client/test/cutlass/qwp/client/QwpQueryClientWalkTrackerTest.java index 4a2544027..b4586893d 100644 --- a/core/src/test/java/io/questdb/client/test/cutlass/qwp/client/QwpQueryClientWalkTrackerTest.java +++ b/core/src/test/java/io/questdb/client/test/cutlass/qwp/client/QwpQueryClientWalkTrackerTest.java @@ -441,10 +441,15 @@ public void testWalk_TransportFailureContinuesWalk() throws Exception { // First port has no server (TCP refused); second is reachable. // WalkTracker must classify the first as TransportError and bind // the second on the same walk (no fall-through reset needed yet). - int portDead = TestPorts.findUnusedPort(); try (TestWebSocketServer ok = new TestWebSocketServer(NOOP_HANDLER)) { ok.setSendServerInfo(true); int portOk = ok.getPort(); + // Probe the dead port only while ok's listener holds portOk: the + // kernel never hands out a port a live listener owns, so portDead + // cannot collide with portOk. Probing first lets the server's own + // bind(0) receive the just-released probe port, and the duplicate + // addr entry then fails config validation. + int portDead = TestPorts.findUnusedPort(); ok.start(); Assert.assertTrue(ok.awaitStart(5, TimeUnit.SECONDS));