From dc6147178b5004b6752afb4ba913524bfb7d538b Mon Sep 17 00:00:00 2001 From: Marko Topolnik Date: Fri, 19 Jun 2026 14:32:09 +0200 Subject: [PATCH] Time only close() in WasUpAllAlong drain test testAsyncCloseDrainSucceedsWhenServerWasUpAllAlong timed the whole try (Sender = fromConfig(...)) { write; flush; } close block against a 2500ms budget, but the assertion budgets close()'s drain latency, not sender construction. Iteration 0 is the first store-and-forward async sender in the JVM, so fromConfig pays a one-time cold-start cost (class loading, JIT, sf buffer mmap). On a loaded CI runner that cold start reached ~3.26s and tripped the assertion, even though close() itself took ~12ms. Move t0 to wrap only sender.close(), matching the sibling test testAsyncCloseDrainSucceedsWhenServerStartsDuringDrain. close() is idempotent, so the try-with-resources auto-close is a no-op. Measured close() latency stays in the single-digit milliseconds across all 20 iterations, well within the 2500ms budget. --- .../test/cutlass/qwp/client/CloseDrainTest.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/src/test/java/io/questdb/client/test/cutlass/qwp/client/CloseDrainTest.java b/core/src/test/java/io/questdb/client/test/cutlass/qwp/client/CloseDrainTest.java index f0a77a5a..ef012229 100644 --- a/core/src/test/java/io/questdb/client/test/cutlass/qwp/client/CloseDrainTest.java +++ b/core/src/test/java/io/questdb/client/test/cutlass/qwp/client/CloseDrainTest.java @@ -358,14 +358,20 @@ public void testAsyncCloseDrainSucceedsWhenServerWasUpAllAlong() throws Exceptio + ";reconnect_initial_backoff_millis=20" + ";reconnect_max_backoff_millis=100" + ";close_flush_timeout_millis=3000;"; - long t0 = System.nanoTime(); try (Sender sender = Sender.fromConfig(cfg)) { sender.table("foo").longColumn("v", i).atNow(); sender.flush(); + // Time only close(): the 2500ms budget covers close()'s + // drain latency. Building the first store-and-forward + // sender carries a one-time cold-start cost (class + // loading, JIT, sf buffer mmap) that belongs to + // construction, not to close(). + long t0 = System.nanoTime(); + sender.close(); + long elapsedMs = (System.nanoTime() - t0) / 1_000_000; + Assert.assertTrue("iteration " + i + " close() took " + elapsedMs + "ms", + elapsedMs < 2500); } - long elapsedMs = (System.nanoTime() - t0) / 1_000_000; - Assert.assertTrue("iteration " + i + " close() took " + elapsedMs + "ms", - elapsedMs < 2500); } } }