mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-06 04:54:29 +08:00
Fix app recovery when the whole runtime goes down
This commit is contained in:
parent
8144afdc26
commit
a976781b69
2 changed files with 31 additions and 2 deletions
|
@ -2507,7 +2507,7 @@ defmodule Livebook.Session.Data do
|
|||
|
||||
Considers only cells that have already been evaluated.
|
||||
"""
|
||||
@spec cell_evaluation_parents(Data.t(), Cell.t()) :: list({Cell.t(), Section.t()})
|
||||
@spec cell_evaluation_parents(t(), Cell.t()) :: list({Cell.t(), Section.t()})
|
||||
def cell_evaluation_parents(data, cell) do
|
||||
for {cell, section} <- Notebook.parent_cells_with_section(data.notebook, cell.id),
|
||||
info = data.cell_infos[cell.id],
|
||||
|
@ -2782,8 +2782,14 @@ defmodule Livebook.Session.Data do
|
|||
defp app_recover({data, _} = data_actions) do
|
||||
evaluable_cells_with_section = Notebook.evaluable_cells_with_section(data.notebook)
|
||||
|
||||
data_actions =
|
||||
if data.runtime_status == :connected do
|
||||
disconnect_runtime(data_actions)
|
||||
else
|
||||
data_actions
|
||||
end
|
||||
|
||||
data_actions
|
||||
|> disconnect_runtime()
|
||||
|> connect_runtime()
|
||||
|> erase_outputs()
|
||||
|> garbage_collect_input_infos()
|
||||
|
|
|
@ -4491,6 +4491,29 @@ defmodule Livebook.Session.DataTest do
|
|||
Data.apply_operation(data, operation)
|
||||
end
|
||||
|
||||
test "when fully executed and then runtime down, recovers by evaluating from scratch" do
|
||||
data =
|
||||
data_after_operations!(Data.new(mode: :app), [
|
||||
{:insert_section, @cid, 0, "s1"},
|
||||
{:insert_cell, @cid, "s1", 0, :code, "c1", %{}},
|
||||
{:insert_cell, @cid, "s1", 1, :code, "c2", %{}},
|
||||
connect_noop_runtime_operations(),
|
||||
evaluate_cells_operations(["setup", "c1", "c2"])
|
||||
])
|
||||
|
||||
operation = {:runtime_down, @cid}
|
||||
|
||||
assert {:ok,
|
||||
%{
|
||||
cell_infos: %{
|
||||
"setup" => %{eval: %{status: :queued}},
|
||||
"c1" => %{eval: %{status: :queued}},
|
||||
"c2" => %{eval: %{status: :queued}}
|
||||
},
|
||||
app_data: %{status: %{execution: :executing}}
|
||||
}, [:app_report_status, :connect_runtime]} = Data.apply_operation(data, operation)
|
||||
end
|
||||
|
||||
test "changes status back to :executed after recovery" do
|
||||
data =
|
||||
data_after_operations!(Data.new(mode: :app), [
|
||||
|
|
Loading…
Add table
Reference in a new issue