Skip to content

[core] Move Redis health check runner back to GCS server main - #55812

Merged
edoakes merged 17 commits into
ray-project:masterfrom
edoakes:eoakes/fix-redis-client-tests
Aug 22, 2025
Merged

edoakes merged 17 commits into
ray-project:masterfrom
edoakes:eoakes/fix-redis-client-tests

Conversation

@edoakes

@edoakes edoakes commented Aug 21, 2025 •

Copy link
Copy Markdown
Collaborator

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.

@edoakes
edoakes requested a review from a team as a code owner August 21, 2025 12:45
@edoakes edoakes added the go add ONLY when ready to merge, run all tests label Aug 21, 2025

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request aims to deflake the Redis client tests. The main change is disabling the Redis health check during tests, which is a reasonable approach given that Redis is torn down between test cases. The change from INFO to DEBUG for logging is also good for reducing log noise.

I found a race condition in TEST_F(RedisStoreClientTest, Complicated) which was likely exposed by another fix in this PR. The AsyncExists check was not waiting for AsyncBatchDelete to complete. I've provided a suggestion to fix this, which should improve test stability.

@edoakes edoakes changed the title [core] Deflake redis client tests [core] Fix TSAN for redis client tests Aug 21, 2025
@edoakes edoakes changed the title [core] Fix TSAN for redis client tests [WIP][core] Fix TSAN for redis client tests Aug 21, 2025
@edoakes
edoakes marked this pull request as draft August 21, 2025 12:55
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]>
@edoakes
edoakes force-pushed the eoakes/fix-redis-client-tests branch from e6389fa to b373556 Compare August 21, 2025 16:15
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]>
@edoakes edoakes changed the title [WIP][core] Fix TSAN for redis client tests [core] Move Redis health check runner back to GCS server main Aug 21, 2025
@edoakes
edoakes marked this pull request as ready for review August 21, 2025 16:24
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-gardener ray-gardener Bot added the core Issues that should be addressed in Ray Core label Aug 21, 2025
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>

@dayshah dayshah left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok with this for now but shouldn't the io service stop and cancel everything before things are destructed

@edoakes

edoakes commented Aug 22, 2025

Copy link
Copy Markdown
Collaborator Author

ok with this for now but shouldn't the io service stop and cancel everything before things are destructed

IMO the PeriodicalRunner should cancel (it does) and join/wait for (it doesn't) any scheduled tasks. That way the lifetime semantics are very clear (anything captured in the callback just needs to live as long as the periodical runner).

@edoakes
edoakes merged commit 9af216b into ray-project:master Aug 22, 2025
jugalshah291 pushed a commit to jugalshah291/ray_fork that referenced this pull request Sep 11, 2025
…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]>
dstrodtman pushed a commit that referenced this pull request Oct 6, 2025
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]>
landscapepainter pushed a commit to landscapepainter/ray that referenced this pull request Nov 17, 2025
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants