Repository navigation
Conversation
There was a problem hiding this comment.
Any chance for documentation? operate, cleanup, and most of the function names are confusing without inspecting the code, please add some documentations, thanks.
There was a problem hiding this comment.
Acutally I just copy them from the original asio.h. There is also no comment there. But I'll try to add some comments.
There was a problem hiding this comment.
I'm curious about the logic:
- From doc, the bytes read is passed to callback
- How do we know all bytes have been read from socket?
- LL145 shows we directly mark ongoing read/write operation as false
There was a problem hiding this comment.
Good question. This might be due to a historical reason. We can ask other team members why we don't use async_read here.
There was a problem hiding this comment.
Actually I'm not quite sure we should use mutex and multi-threading here.
The only operation which might involve multi-threaded operation is operate invoked from another thread, all other operations are posted into io_service; curious why do we need concurrent operate calls?
There was a problem hiding this comment.
Actually, I don't know either. But I suspect that the predecessors decided to use a mutex because they saw this: https://github.com/redis/hiredis/blob/8d8703ee6149ffd3b38cebedd71ad8d1fac63cc7/README.md?plain=1#L152.
There was a problem hiding this comment.
They want to make redisAsyncContext thread-safe.
bef27a1 to
334dfe6
Compare
jjyao
left a comment
There was a problem hiding this comment.
LG. There is merge conflict.
There was a problem hiding this comment.
This used to be empty, is it intentional change?
There was a problem hiding this comment.
Referenced from adapters examples in hiredis.
Signed-off-by: Chi-Sheng Liu <[email protected]>
Signed-off-by: Chi-Sheng Liu <[email protected]>
Signed-off-by: Chi-Sheng Liu <[email protected]>
Signed-off-by: Chi-Sheng Liu <[email protected]>
Signed-off-by: Chi-Sheng Liu <[email protected]>
334dfe6 to
3be9873
Compare
| namespace ray { | ||
| namespace gcs { | ||
| // Adaptor callback functions for hiredis redis_async_context->ev | ||
| void CallbackAddRead(void *); |
There was a problem hiding this comment.
You don't need to place it in header file...
…ject#49000) Signed-off-by: Chi-Sheng Liu <[email protected]> Signed-off-by: ujjawal-khare <[email protected]>
…64204) ## Description While testing, `gcs_server` crashed with a SIGSEGV during a Redis connection error (failover). Looking for a fix I found #48781, which solves it by reconnecting to Redis, but it was closed as stale without being merged. Its main blocker at the time (a dependency cycle in the GCS Redis client) has since been resolved by #49000 and #55655, so this PR ports that reconnect approach onto the current version. When the Redis connection is lost, an in-flight request retries against the released connection and dereferences a null pointer, crashing the GCS. This PR reconnects to Redis when the connection is dead so requests retry on a healthy connection instead of crashing. ## Related issues - Fixes #53475 - Based on #48781 by @MortalHappiness (closed without merge); credit for the original design. ## Additional information Reproduction: 1. Run a cluster with GCS fault tolerance backed by an HA Redis. 2. While the cluster is up, trigger a Redis primary failover e.g. kill/replace the Redis primary so a replica is promoted. 3. Before this PR, `gcs_server` exits with signal 11 and the head pod restarts; after this PR it reconnects to the new primary and continues. The exact crash we observed: ``` 2026-06-18 04:54:00,110 ERROR scripts.py:1219 -- Some Ray subprocesses exited unexpectedly: gcs_server [exit code=-11 (signal 11)] [2026-06-18 04:55:36,551 E 42 42] (gcs_server) logging.cc:474: *** SIGSEGV received at time=1781726136 on cpu 0 *** [2026-06-18 04:55:36,551 E 42 42] (gcs_server) logging.cc:474: PC: @ 0x55719802efb8 (unknown) ray::gcs::RedisRequestContext::RedisResponseFn() [2026-06-18 04:55:36,551 E 42 42] (gcs_server) logging.cc:474: @ 0x7f6c34fb6520 (unknown) (unknown) [2026-06-18 04:55:36,551 E 42 42] (gcs_server) logging.cc:474: @ 0x55719802f1f9 1168 ray::gcs::RedisRequestContext::Run() [2026-06-18 04:55:36,551 E 42 42] (gcs_server) logging.cc:474: @ 0x55719801a748 224 ray::gcs::RedisStoreClient::AsyncCheckHealth() ``` --- ## Update: I first took the reconnect approach above, but a robust in-place reconnect needs `Connect()` to be non-fatal (it `RAY_CHECK`s today, so a transient failover still aborts `gcs_server`) - the larger refactor that stalled #48781. So this PR instead takes the minimal fix: null-guard the dereference so the request fails gracefully instead of crashing, and GCS fault tolerance recovers as today. Full reconnect is left as a follow-up (#48781). Signed-off-by: Dongjun Na <[email protected]>
…ay-project#64204) ## Description While testing, `gcs_server` crashed with a SIGSEGV during a Redis connection error (failover). Looking for a fix I found ray-project#48781, which solves it by reconnecting to Redis, but it was closed as stale without being merged. Its main blocker at the time (a dependency cycle in the GCS Redis client) has since been resolved by ray-project#49000 and ray-project#55655, so this PR ports that reconnect approach onto the current version. When the Redis connection is lost, an in-flight request retries against the released connection and dereferences a null pointer, crashing the GCS. This PR reconnects to Redis when the connection is dead so requests retry on a healthy connection instead of crashing. ## Related issues - Fixes ray-project#53475 - Based on ray-project#48781 by @MortalHappiness (closed without merge); credit for the original design. ## Additional information Reproduction: 1. Run a cluster with GCS fault tolerance backed by an HA Redis. 2. While the cluster is up, trigger a Redis primary failover e.g. kill/replace the Redis primary so a replica is promoted. 3. Before this PR, `gcs_server` exits with signal 11 and the head pod restarts; after this PR it reconnects to the new primary and continues. The exact crash we observed: ``` 2026-06-18 04:54:00,110 ERROR scripts.py:1219 -- Some Ray subprocesses exited unexpectedly: gcs_server [exit code=-11 (signal 11)] [2026-06-18 04:55:36,551 E 42 42] (gcs_server) logging.cc:474: *** SIGSEGV received at time=1781726136 on cpu 0 *** [2026-06-18 04:55:36,551 E 42 42] (gcs_server) logging.cc:474: PC: @ 0x55719802efb8 (unknown) ray::gcs::RedisRequestContext::RedisResponseFn() [2026-06-18 04:55:36,551 E 42 42] (gcs_server) logging.cc:474: @ 0x7f6c34fb6520 (unknown) (unknown) [2026-06-18 04:55:36,551 E 42 42] (gcs_server) logging.cc:474: @ 0x55719802f1f9 1168 ray::gcs::RedisRequestContext::Run() [2026-06-18 04:55:36,551 E 42 42] (gcs_server) logging.cc:474: @ 0x55719801a748 224 ray::gcs::RedisStoreClient::AsyncCheckHealth() ``` --- ## Update: I first took the reconnect approach above, but a robust in-place reconnect needs `Connect()` to be non-fatal (it `RAY_CHECK`s today, so a transient failover still aborts `gcs_server`) - the larger refactor that stalled ray-project#48781. So this PR instead takes the minimal fix: null-guard the dereference so the request fails gracefully instead of crashing, and GCS fault tolerance recovers as today. Full reconnect is left as a follow-up (ray-project#48781). Signed-off-by: Dongjun Na <[email protected]>
…ay-project#64204) ## Description While testing, `gcs_server` crashed with a SIGSEGV during a Redis connection error (failover). Looking for a fix I found ray-project#48781, which solves it by reconnecting to Redis, but it was closed as stale without being merged. Its main blocker at the time (a dependency cycle in the GCS Redis client) has since been resolved by ray-project#49000 and ray-project#55655, so this PR ports that reconnect approach onto the current version. When the Redis connection is lost, an in-flight request retries against the released connection and dereferences a null pointer, crashing the GCS. This PR reconnects to Redis when the connection is dead so requests retry on a healthy connection instead of crashing. ## Related issues - Fixes ray-project#53475 - Based on ray-project#48781 by @MortalHappiness (closed without merge); credit for the original design. ## Additional information Reproduction: 1. Run a cluster with GCS fault tolerance backed by an HA Redis. 2. While the cluster is up, trigger a Redis primary failover e.g. kill/replace the Redis primary so a replica is promoted. 3. Before this PR, `gcs_server` exits with signal 11 and the head pod restarts; after this PR it reconnects to the new primary and continues. The exact crash we observed: ``` 2026-06-18 04:54:00,110 ERROR scripts.py:1219 -- Some Ray subprocesses exited unexpectedly: gcs_server [exit code=-11 (signal 11)] [2026-06-18 04:55:36,551 E 42 42] (gcs_server) logging.cc:474: *** SIGSEGV received at time=1781726136 on cpu 0 *** [2026-06-18 04:55:36,551 E 42 42] (gcs_server) logging.cc:474: PC: @ 0x55719802efb8 (unknown) ray::gcs::RedisRequestContext::RedisResponseFn() [2026-06-18 04:55:36,551 E 42 42] (gcs_server) logging.cc:474: @ 0x7f6c34fb6520 (unknown) (unknown) [2026-06-18 04:55:36,551 E 42 42] (gcs_server) logging.cc:474: @ 0x55719802f1f9 1168 ray::gcs::RedisRequestContext::Run() [2026-06-18 04:55:36,551 E 42 42] (gcs_server) logging.cc:474: @ 0x55719801a748 224 ray::gcs::RedisStoreClient::AsyncCheckHealth() ``` --- ## Update: I first took the reconnect approach above, but a robust in-place reconnect needs `Connect()` to be non-fatal (it `RAY_CHECK`s today, so a transient failover still aborts `gcs_server`) - the larger refactor that stalled ray-project#48781. So this PR instead takes the minimal fix: null-guard the dereference so the request fails gracefully instead of crashing, and GCS fault tolerance recovers as today. Full reconnect is left as a follow-up (ray-project#48781). Signed-off-by: Dongjun Na <[email protected]> Signed-off-by: 400Ping <[email protected]>
Why are these changes needed?
While working on #48781, we found that
RedisAsioClientandRedisAsyncContextstrongly depends on each other, and it is a 1-1 mapping. Therefore, we decide to merge the implementation ofRedisAsioClientintoRedisAsyncContextto make it self-contained.The class diagram before this PR:
Note:
redisAsyncContextimplicitly usesRedisAsioClientvia the callback function.The class diagram after this PR:
Related issue number
N/A
Checks
git commit -s) in this PR.scripts/format.shto lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/under thecorresponding
.rstfile.