[core] Fix the race condition in the new resource broadcasting. - #32798
Conversation
|
It's a race condition and so hard to add a unit test for this. let me know if anyone has good ideas. |
|
release testing with fixing: |
rkooo567
left a comment
There was a problem hiding this comment.
The change itself lgtm. But this makes me think it's probably better making the module thread-safe rather than relying on posting to the io service? Seems like the threading model is very prone to error rn (I know it is a common problem in Ray, but I am bringing this up because it is a new module and we can enforce some good practice here?)
|
@rkooo567 making it thread safe is the same as posting things to io-context. Basically, you can replace posting => mutex lock. So that's why I'm not putting mutex there. And issues come from gRPC's callback is in gRPC thread. A good practice from gRPC is that don't hold the thread for long time.
The concerns or the difficulties should be handled in gRPC/threading related work. |
|
Hmmm, the test entered the terminated status... Seems the cluster is terminated... I'll check what's going on there. |
|
I think it might be related to the migration to jobs on v2. Let me check. |
|
Confirmed that it's an infra issue. Merge this one. |
…project#32798) The root cause is that disconnect is called not in io_context which in the end accessing the invalid memory. Disconnect needs to be called exactly once. In gRPC, read/write might error and OnCancel also means error just with different semantics. But we need to ensure disconnect is only called once. Previously, disconnect might be called in gRPC threads, main thread/... and this PR enforce them called within the io context. This fix the release test long_running_node_failures. Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
…project#32798) The root cause is that disconnect is called not in io_context which in the end accessing the invalid memory. Disconnect needs to be called exactly once. In gRPC, read/write might error and OnCancel also means error just with different semantics. But we need to ensure disconnect is only called once. Previously, disconnect might be called in gRPC threads, main thread/... and this PR enforce them called within the io context. This fix the release test long_running_node_failures.
…project#32798) The root cause is that disconnect is called not in io_context which in the end accessing the invalid memory. Disconnect needs to be called exactly once. In gRPC, read/write might error and OnCancel also means error just with different semantics. But we need to ensure disconnect is only called once. Previously, disconnect might be called in gRPC threads, main thread/... and this PR enforce them called within the io context. This fix the release test long_running_node_failures. Signed-off-by: elliottower <elliot@elliottower.com>
Why are these changes needed?
The root cause is that disconnect is called not in io_context which in the end accessing the invalid memory. Disconnect needs to be called exactly once.
In gRPC, read/write might error and OnCancel also means error just with different semantics. But we need to ensure disconnect is only called once. Previously, disconnect might be called in gRPC threads, main thread/... and this PR enforce them called within the io context.
This fix the release test long_running_node_failures.
Related issue number
Checks
git commit -s) in this PR.scripts/format.shto lint the changes in this PR.