Repository navigation
[Core] Debugging flaky redis connection on windows - #67085
Conversation
Signed-off-by: davik <[email protected]>
Signed-off-by: davik <[email protected]>
Signed-off-by: davik <[email protected]>
b5cb554 to
bf1ae96
Compare
Signed-off-by: davik <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces a Windows-specific fix for configuring TCP keepalive on asynchronous Redis connections. Since Winsock does not support setting socket options while a connection is in progress, a new helper function WaitForRedisConnect is added to wait for the connection to complete using select before applying the keepalive configuration. Additionally, a timeout constant kRedisConnectWaitTimeoutSeconds is defined. There are no review comments to address, and I have no further feedback to provide.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 75055d4. Configure here.
|
LGTM. One thing to add: Setting keepalive before connect() would be cleaner (SO_KEEPALIVE docs allow it), but hiredis creates the socket and connects it in one step (net.c), with no hook in between. So we wait for the connection to be ready here. |

Description
We have recently observed after #65424 (introduced keep alive tcp connection between gcs and redis on all operating systems) was merged,
redis_async_context_testwould fail periodically on Windows in postmerge. Initial investigation on the failed runs showed each of the failed test logging something similar to the following before failure:We have managed to replicate the issue on our CI machine, and upon adding more detailed logging, we have observed the following.
On Windows, when we attempt to configure
keepalivevia hiredis'sredisEnableKeepAliveWithIntervalimmediately after making the async connection, we periodically run into the IO error shown above. However, when we broke down the individudal components ofredisEnableKeepAliveWithInterval, we observed that the system actually failed due toWSA error=10022when we attempted to setSO_KEEPALIVEon the async connection.What this PR introduces
Thus, this PR introduces a select to wait on the async connection in windows. With this change, we will only write keepalive to the connection once we are sure it is ready (per
select's documentation ). The change has been stress tested on theredis_async_context_testand we have observed the original flaky failures go away.Related issues
Additional information
Passing redis test run in post merge: https://buildkite.com/ray-project/postmerge/builds/20371#01a14b8e-d72f-4de4-8426-35d38340f0bc