Repository navigation
[core] Combine RedisClient into RedisStoreClient - #55655
Conversation
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
| ray_cc_library( | ||
| name = "gcs", | ||
| deps = [ | ||
| ":gcs_callback", | ||
| ":gcs_pb_util", | ||
| ":gcs_redis_client", | ||
| "//src/ray/rpc:node_manager_client", | ||
| ], | ||
| ) |
There was a problem hiding this comment.
Unused (and we shouldn't have vague/bloated targets like this)
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
| gcs_publisher_ = std::make_unique<gcs::GcsPublisher>(std::move(publisher)); | ||
| gcs_table_storage_ = std::make_unique<gcs::InMemoryGcsTableStorage>(); | ||
| gcs_table_storage_ = | ||
| std::make_unique<gcs::GcsTableStorage>(std::make_unique<InMemoryStoreClient>()); |
There was a problem hiding this comment.
should be ObservableStoreClient
I have bigger questions on the value of the ObservableStoreClient in its current state and what it provides beyond the io context stats... but don't need to go there rn...
There was a problem hiding this comment.
yeah it should get nuked
for this test though I don't think it matters which we use
| int port; | ||
|
|
||
| // Redis username and password. | ||
| std::string username = ""; |
There was a problem hiding this comment.
nit: the empty strings should be unnecessary as the default ctor for strings does this.
There was a problem hiding this comment.
true, but I like it specifying it explicitly to signal to the reader that they're optional
There was a problem hiding this comment.
actually, I don't think this is even true because this is a struct. so the ones without explicit defaults must be specified.
There was a problem hiding this comment.
(correct me if I'm wrong)
|
|
||
| /// Get or connect to a redis server | ||
| std::shared_ptr<RedisClient> CreateRedisClient(instrumented_io_context &io_service); | ||
| std::unique_ptr<RedisStoreClient> CreateRedisStoreClient( |
There was a problem hiding this comment.
So a rabbit hole I've been down lately is that we make liberal use of instrumented_io_context in a lot of places where we don't seem to intend to use the instrumentation. Will we always use the instrumentation when creating a redis client (though I realize it was doing so before)? If not we can just use the raw boost one.
There was a problem hiding this comment.
For completeness I think we should leave it in for now given this is the only real visibility we have into an issue such as the redis client slowing down.
This and @dayshah's point above make it clear that we don't have a solid observability story for these clients...
ZacAttack
left a comment
There was a problem hiding this comment.
Looks like a good cleanup! Just left the one question
- `RedisClient` was a thin and meaningless abstraction over `RedisContext`, so now the `RedisStoreClient` uses the `RedisContext` directly. - The only other user of `RedisClient` was the "periodic health checker." I've moved this into `RedisStoreClient` as well. - Also removed some unnecessary child classes: `InMemoryGcsTableStorage`, `RedisGcsTableStorage`. Before merging I plan to fold the `RayConfig` options used in `RedisStoreClient` into the `RedisClientOptions`. --------- Signed-off-by: Edward Oakes <[email protected]> Signed-off-by: Andrew Grosser <[email protected]>
TSAN tests are failing after my refactor PR: #55655 This is because the `PeriodicalRunner` does not wait for any spawned async tasks to complete in its destructor. In the current setup, after the `PeriodicalRunner` is destroyed, the `RedisStoreClient` is immediately destroyed. However, there may still be tasks on the IO service that didn't get cancelled and will try to access the `RedisStoreClient`, leading to invalid memory accesses. Simplest fix is to move the `PeriodicalRunner` back to `gcs_server.cc` and capture a shared pointer to the client in the callback. I also considered fixing the `PeriodicalRunner` destructor, but that code is hard to navigate right now. --------- Signed-off-by: Edward Oakes <[email protected]>
- `RedisClient` was a thin and meaningless abstraction over `RedisContext`, so now the `RedisStoreClient` uses the `RedisContext` directly. - The only other user of `RedisClient` was the "periodic health checker." I've moved this into `RedisStoreClient` as well. - Also removed some unnecessary child classes: `InMemoryGcsTableStorage`, `RedisGcsTableStorage`. Before merging I plan to fold the `RayConfig` options used in `RedisStoreClient` into the `RedisClientOptions`. --------- Signed-off-by: Edward Oakes <[email protected]> Signed-off-by: jugalshah291 <[email protected]>
…oject#55812) TSAN tests are failing after my refactor PR: ray-project#55655 This is because the `PeriodicalRunner` does not wait for any spawned async tasks to complete in its destructor. In the current setup, after the `PeriodicalRunner` is destroyed, the `RedisStoreClient` is immediately destroyed. However, there may still be tasks on the IO service that didn't get cancelled and will try to access the `RedisStoreClient`, leading to invalid memory accesses. Simplest fix is to move the `PeriodicalRunner` back to `gcs_server.cc` and capture a shared pointer to the client in the callback. I also considered fixing the `PeriodicalRunner` destructor, but that code is hard to navigate right now. --------- Signed-off-by: Edward Oakes <[email protected]> Signed-off-by: jugalshah291 <[email protected]>
- `RedisClient` was a thin and meaningless abstraction over `RedisContext`, so now the `RedisStoreClient` uses the `RedisContext` directly. - The only other user of `RedisClient` was the "periodic health checker." I've moved this into `RedisStoreClient` as well. - Also removed some unnecessary child classes: `InMemoryGcsTableStorage`, `RedisGcsTableStorage`. Before merging I plan to fold the `RayConfig` options used in `RedisStoreClient` into the `RedisClientOptions`. --------- Signed-off-by: Edward Oakes <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
TSAN tests are failing after my refactor PR: #55655 This is because the `PeriodicalRunner` does not wait for any spawned async tasks to complete in its destructor. In the current setup, after the `PeriodicalRunner` is destroyed, the `RedisStoreClient` is immediately destroyed. However, there may still be tasks on the IO service that didn't get cancelled and will try to access the `RedisStoreClient`, leading to invalid memory accesses. Simplest fix is to move the `PeriodicalRunner` back to `gcs_server.cc` and capture a shared pointer to the client in the callback. I also considered fixing the `PeriodicalRunner` destructor, but that code is hard to navigate right now. --------- Signed-off-by: Edward Oakes <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
- `RedisClient` was a thin and meaningless abstraction over `RedisContext`, so now the `RedisStoreClient` uses the `RedisContext` directly. - The only other user of `RedisClient` was the "periodic health checker." I've moved this into `RedisStoreClient` as well. - Also removed some unnecessary child classes: `InMemoryGcsTableStorage`, `RedisGcsTableStorage`. Before merging I plan to fold the `RayConfig` options used in `RedisStoreClient` into the `RedisClientOptions`. --------- Signed-off-by: Edward Oakes <[email protected]>
…oject#55812) TSAN tests are failing after my refactor PR: ray-project#55655 This is because the `PeriodicalRunner` does not wait for any spawned async tasks to complete in its destructor. In the current setup, after the `PeriodicalRunner` is destroyed, the `RedisStoreClient` is immediately destroyed. However, there may still be tasks on the IO service that didn't get cancelled and will try to access the `RedisStoreClient`, leading to invalid memory accesses. Simplest fix is to move the `PeriodicalRunner` back to `gcs_server.cc` and capture a shared pointer to the client in the callback. I also considered fixing the `PeriodicalRunner` destructor, but that code is hard to navigate right now. --------- Signed-off-by: Edward Oakes <[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]>
RedisClientwas a thin and meaningless abstraction overRedisContext, so now theRedisStoreClientuses theRedisContextdirectly.RedisClientwas the "periodic health checker." I've moved this intoRedisStoreClientas well.InMemoryGcsTableStorage,RedisGcsTableStorage.Before merging I plan to fold the
RayConfigoptions used inRedisStoreClientinto theRedisClientOptions.