Skip to content

Commit 94a0ae6

Browse files
committed
Isolate flock retry ordering test
EngineClosePublishAfterFlockReleaseTest started the shared retry driver after injecting an invalid slot-lock descriptor. It then returned before the driver's initial park expired. A following test could observe the global driver as active and fail, as Windows CI did. Inject a synchronous retry-driver start failure for this explicit-close retry test. Restore the factory in a nested finally block. Dedicated retry-driver tests continue to cover the asynchronous lifecycle.
1 parent 21345b0 commit 94a0ae6

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

core/src/test/java/io/questdb/client/test/cutlass/qwp/client/sf/cursor/EngineClosePublishAfterFlockReleaseTest.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,15 @@ public void testUnconfirmedFlockReleaseKeepsCloseIncompleteUntilRetry() throws E
200200
fdField.setAccessible(true);
201201
int realFd = fdField.getInt(slotLock);
202202
assertTrue("precondition: live flock fd", realFd >= 0);
203+
204+
// This test owns the explicit close() retry. Prevent the shared
205+
// asynchronous retry driver from racing it and from surviving into
206+
// another test class; FlockReleaseRetryDriverTest covers the real
207+
// driver lifecycle separately. A start failure synchronously clears
208+
// the shared retry queue and resets the engine's scheduling flag.
209+
CursorSendEngine.setFlockReleaseRetryThreadFactory(task -> {
210+
throw new IllegalStateException("retry driver disabled for explicit close retry test");
211+
});
203212
try {
204213
// A non-negative fd no process has open: close(2) fails EBADF,
205214
// so finishClose's release() confirmation fails.
@@ -230,11 +239,15 @@ public void testUnconfirmedFlockReleaseKeepsCloseIncompleteUntilRetry() throws E
230239
// good — eventual completion implies reusable capacity.
231240
}
232241
} finally {
233-
// If an assertion failed before the successful retry, restore
234-
// and release the real fd so the test never leaks a flock.
235-
if (!engine.isCloseCompleted()) {
236-
fdField.setInt(slotLock, realFd);
237-
assertTrue("restored fd must release cleanly", slotLock.release());
242+
try {
243+
// If an assertion failed before the successful retry, restore
244+
// and release the real fd so the test never leaks a flock.
245+
if (!engine.isCloseCompleted()) {
246+
fdField.setInt(slotLock, realFd);
247+
assertTrue("restored fd must release cleanly", slotLock.release());
248+
}
249+
} finally {
250+
CursorSendEngine.setFlockReleaseRetryThreadFactory(null);
238251
}
239252
}
240253
});

0 commit comments

Comments
 (0)