From 38a07ccbe9193c898241ad09aaed706127fd6412 Mon Sep 17 00:00:00 2001 From: GenericJam Date: Fri, 23 Oct 2026 22:53:19 -0600 Subject: [PATCH 1/2] StoreTest: wait for the table holder to die before teardown (MOB-502) --- test/mob/diag/store_test.exs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/mob/diag/store_test.exs b/test/mob/diag/store_test.exs index cfa78a8e..4f40fe83 100644 --- a/test/mob/diag/store_test.exs +++ b/test/mob/diag/store_test.exs @@ -734,7 +734,10 @@ defmodule Mob.Diag.StoreTest do assert_receive :held - on_exit(fn -> Process.exit(holder, :kill) end) + # Wait for the death, not just send the kill: the holder's tables go + # with it, and a death landing during tear_down's whereis-then-delete + # made that delete raise (MOB-502). + on_exit(fn -> kill(holder) end) assert Store.guard(TestStore, :fallback, fn -> raise "boom" end) == :fallback assert Store.health(TestStore).lost == 1 From fa37d3f32b4a303028c6add4e173fae4074525c0 Mon Sep 17 00:00:00 2001 From: GenericJam Date: Fri, 23 Oct 2026 23:04:38 -0600 Subject: [PATCH 2/2] StoreTest: wait for the restarted heir to hold the tables before teardown (MOB-502 review) --- test/mob/diag/store_test.exs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/mob/diag/store_test.exs b/test/mob/diag/store_test.exs index 4f40fe83..8aa752fe 100644 --- a/test/mob/diag/store_test.exs +++ b/test/mob/diag/store_test.exs @@ -255,7 +255,18 @@ defmodule Mob.Diag.StoreTest do kill(first) replacement = await_replacement(TestStore, first) - kill(Process.whereis(Mob.Diag.Heir)) + heir = Process.whereis(Mob.Diag.Heir) + kill(heir) + + # The owner re-points each table at the restarted heir on its own; wait + # for that, or teardown can delete a table mid-setopts and crash the + # owner (MOB-502). + ProcessHelpers.eventually(fn -> + new_heir = Process.whereis(Mob.Diag.Heir) + + is_pid(new_heir) and new_heir != heir and + Enum.all?(TestStore.tables(), fn {t, _} -> :ets.info(t, :heir) == new_heir end) + end) assert owner(TestStore) == replacement assert held_by(TestStore) == [:owner, :owner]