Refactor heartbeat to shutdown cleanly #1135
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With Julia 1.11.2 (also tested 1.10.7), I'm seeing segfaults when shutting down an idle
Julia kernel (with current [email protected]) in Jupyter on Linux.
Reproducible by opening/starting a notebook, and then shutting down after the kernel isEDIT: I can no longer reproduce this, but the change still seems like a good idea?connected and idle.
There are several errors in the segfault dump, but the heartbeat thread is notable
The ZMQ docs state "zmq_proxy() runs in the current thread and returns only
if/when the current context is closed."
The heartbeat socket doesn't need to be global, as nothing else touches
it. So, if we create the heartbeat socket in a
Context
that has a global ref,we can close the context, which will cause zmq_proxy to return and then
that thread to end/finish.
With this change, I'm not sure whether the
jl_gc_safe_enter
ccall is necessary?