-
-
Notifications
You must be signed in to change notification settings - Fork 83
fix(engine): isolate search store from async load crashes #369
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -368,6 +368,7 @@ defmodule Engine.Search.StoreTest do | |||||
| defp with_a_started_store(project, backend) do | ||||||
| destroy_backend(backend, project) | ||||||
|
|
||||||
| start_supervised!({Task.Supervisor, name: Engine.TaskSupervisor}) | ||||||
| start_supervised!(Dispatch) | ||||||
| start_supervised!(backend) | ||||||
| start_supervised!({Store, [project, &default_create/1, &default_update/2, backend]}) | ||||||
|
|
@@ -400,6 +401,7 @@ defmodule Engine.Search.StoreTest do | |||||
| setup %{project: project} do | ||||||
| destroy_backend(Ets, project) | ||||||
|
|
||||||
| start_supervised!({Task.Supervisor, name: Engine.TaskSupervisor}) | ||||||
| start_supervised!(Dispatch) | ||||||
| start_supervised!(Ets) | ||||||
|
|
||||||
|
|
@@ -458,4 +460,37 @@ defmodule Engine.Search.StoreTest do | |||||
| assert received_project == project | ||||||
| end | ||||||
| end | ||||||
|
|
||||||
| describe "async load crash recovery" do | ||||||
| setup %{project: project} do | ||||||
| destroy_backend(Ets, project) | ||||||
|
|
||||||
| start_supervised!({Task.Supervisor, name: Engine.TaskSupervisor}) | ||||||
| start_supervised!(Dispatch) | ||||||
| start_supervised!(Ets) | ||||||
|
|
||||||
| crashing_create = fn _project -> | ||||||
| raise "index build exploded" | ||||||
| end | ||||||
|
|
||||||
| start_supervised!({Store, [project, crashing_create, &default_update/2, Ets]}) | ||||||
|
|
||||||
| assert_eventually alive?() | ||||||
|
|
||||||
| on_exit(fn -> | ||||||
| after_each_test(Ets, project) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this after each test function can probably be deleted, but we can deal with that in a different pr (not you, just as a note for myself) |
||||||
| end) | ||||||
|
|
||||||
| {:ok, project: project} | ||||||
| end | ||||||
|
|
||||||
| test "store survives when async load task crashes" do | ||||||
| pid = Process.whereis(Store) | ||||||
| Store.enable() | ||||||
| # Allow time for the task to crash and the DOWN message to be processed. | ||||||
| Process.sleep(100) | ||||||
|
Comment on lines
+490
to
+491
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest having the function that raises send a messsage to the test process instead, and we can assert_receive on that instead of waiting. |
||||||
|
|
||||||
| assert Process.alive?(pid) | ||||||
| end | ||||||
| end | ||||||
| end | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.