Bug: fix IPC named lock server-side waiter leak on client timeout - #1901
Merged
Conversation
When a client times out waiting for lock acquisition, the server-side context and waiter were leaked, corrupting lock state for subsequent operations. This was the root cause of flaky IPC lock tests on Windows, where higher IPC latency widened the race window. Three fixes: - IpcNamedLock: when lock() times out, send REQUEST_CLOSE to clean up the server-side context instead of silently returning false - IpcClient.send(): remove the response entry from the responses map on timeout so late server responses don't hit stale entries - IpcClient.receive(): gracefully ignore late responses for timed-out requests instead of throwing "Protocol error" Re-enable IPC lock tests on Windows now that the protocol handles timeout correctly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cstamas
approved these changes
Jun 7, 2026
slachiewicz
approved these changes
Jun 7, 2026
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.
Fixes #1743
Problem
The IPC lock tests are increasingly flaky on Windows CI. The root cause is a protocol-level bug where the server accumulates orphaned waiters and contexts when clients time out waiting for lock acquisition.
The race condition
When two threads compete for an exclusive lock via IPC:
CompletableFuture.get(time, unit)times out →doLockExclusively()returnsfalseresponsesmapOn Windows, higher IPC latency widens the race window significantly.
Fix
Three targeted changes:
IpcNamedLock.doLockShared()/doLockExclusively(): Whenclient.lock()throwsTimeoutException, sendclient.unlock(contextId)to clean up the server-side context and waiter before returningfalse. Previously the context was leaked.IpcClient.send(): OnTimeoutException, remove theCompletableFuturefrom theresponsesmap so late server responses don't hit stale entries.IpcClient.receive(): When the response map lookup returnsnull(response arrived for a timed-out request),continuegracefully instead of throwingIllegalStateException("Protocol error")and killing the connection.Re-enabled all three IPC test classes on Windows (
@DisabledOnOs(OS.WINDOWS)removed fromIpcAdapterIT,IpcAdapterNoForkIT,IpcNamedLockFactoryIT).All 32 tests pass consistently.