-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kernel's execution state is not updated after the kernel is crashed while executing code #1395
Comments
FWIW JupyterLab is able to work around this condition (although it is not pretty):
My thinking earlier was that kernel simply cannot send a message when it dies because it is dead, but indeed a kernel manager might be able to handle it. I guess the state should not be PS. What is kernel activity monitor? Is it related to https://github.com/jupyter-server/jupyter-resource-usage? |
There is a ´start_watching_activity´ in jupyter server's When the kernel crashes with opened Notebook 7/JupyterLab UI the state is updated correctly on the server, but when the kernel process dies when UI is closed then the execution state is always shown as ´busy´. Incorrect state could also impact on kernel culling logic because and execution state is monitored in https://github.com/jupyter-server/jupyter_server/blob/main/jupyter_server/services/kernels/kernelmanager.py#L664 |
My idea of a so-called monitor may coincide with the idea of a server side execution like jupyterlab/jupyterlab#15448 When we can execute cell with a single command and move document changes to the backend, we can implement a process like jupyterlab/jupyterlab#12455 (Not entirely dependent on the kernel itself, but on its |
Maybe #990 could solve this? |
Description
A Kernel's execution state is not updated when the kernel crashes while executing code in the background (e.g. due to Out Of Memory issue) with closed Notebook UI.
As a result the kernel state is reported as ´busy´ after the kernel is automatically restarted.
Reproduce
[I 2024-02-14 20:23:44.492 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (1/5), keep random ports
/api/kernels
endpoint[{"id": "0fadc495-97a3-4049-9c4c-adf2e37a416d", "name": "python3", "last_activity": "2024-02-14T20:22:57.083666Z", "execution_state": "busy", "connections": 0}]
The issue happens because a kernel activity monitor updates an execution state based on status messages sent via iopub channel: https://github.com/jupyter-server/jupyter_server/blob/main/jupyter_server/services/kernels/kernelmanager.py#L535-L572.
When the kernel is restarted after crashing and there is no notebook opened in the Browser, there is no kernel_info request sent to the kernel and there is no status message sent via iopub channel to kernel clients. As a results the kernel activity monitor is not able to identify that the kernel was restarted and switched to idle state.
Expected behavior
Kernel switches to idle state after it was successfully restarted
Context
Troubleshoot Output
Command Line Output
Browser Output
The text was updated successfully, but these errors were encountered: