Skip to content

[core][rdt] nixl: follow-ups to #67389 - #67682

Merged
Sparks0219 merged 4 commits into
ray-project:masterfrom
BatshevaBlack:rdt-nixl-test-nit
Nov 3, 2026
Merged

Sparks0219 merged 4 commits into
ray-project:masterfrom
BatshevaBlack:rdt-nixl-test-nit

Conversation

@BatshevaBlack

Copy link
Copy Markdown
Contributor

Changes

  • Test nit. Remove an unneeded gc.collect() in test_nixl_concurrent_batched_get_with_agent_version_change. wait_tensor_freed already waits for the free.
  • Handles released while polling. _finish_transfers polled handles that a garbage-collection finalizer on the same thread could release, leading to a use after free. While an agent's transfers are being polled, _cleanup_transfer now defers releasing handles and _finish_transfers releases them when polling ends. This replaces the xfer_handle in inflight check, which narrowed the window but didn't close it.
  • Finalizer under the cache lock. Garbage collection could run _cleanup_transfer on a thread holding _remote_agent_cache_lock, where waiting for an agent lock can deadlock with a thread that holds that agent lock and wants the cache lock. Cache-lock sections now go through _cache_guard(). While a thread holds the lock, _cleanup_transfer defers its work and the guard replays it after releasing the lock.

@BatshevaBlack
BatshevaBlack requested a review from a team as a code owner November 2, 2026 11:28
…ansfers

A finalizer running on the polling thread could release a handle that _finish_transfers was about to check. Handles released during polling are now released after it ends.

Signed-off-by: BatshevaBlack <[email protected]>
…the cache lock

Garbage collection can run _cleanup_transfer on a thread that holds the remote agent cache lock, where waiting for an agent lock can deadlock with a thread holding that agent lock. While a thread holds the cache lock, _cleanup_transfer now defers to the release of the lock.

Signed-off-by: BatshevaBlack <[email protected]>

@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 introduces a mechanism to defer transfer cleanups and handle releases in nixl_tensor_transport.py to prevent deadlocks when garbage collection runs during lock acquisition. It implements a _cache_guard context manager to defer cleanups while holding the cache lock and updates _finish_transfers to defer handle releases during polling. Additionally, a redundant gc.collect() call is removed from the tests. The review feedback correctly identifies potential robustness issues where exceptions raised during deferred cleanups or handle releases within finally blocks could propagate and interrupt subsequent operations, recommending wrapping these calls in try...except blocks.

…agate

Run each deferred cleanup and each deferred handle release best effort, logging errors, so one failure does not skip the rest or fail the fetch that triggered them.

Signed-off-by: BatshevaBlack <[email protected]>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 93eb780. Configure here.

@ray-gardener ray-gardener Bot added core Issues that should be addressed in Ray Core community-contribution Contributed by the community labels Nov 2, 2026
@Sparks0219 Sparks0219 added the go add ONLY when ready to merge, run all tests label Nov 3, 2026

@Sparks0219 Sparks0219 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.

Thanks for the quick follow ups! LGTM 🚢

@Sparks0219
Sparks0219 enabled auto-merge (squash) November 3, 2026 23:43
@Sparks0219
Sparks0219 merged commit b3db461 into ray-project:master Nov 3, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community 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.

2 participants