From ed294f8b1d52534b9464179f6c1da97afac90d02 Mon Sep 17 00:00:00 2001 From: Bart van Zon Date: Wed, 26 May 2021 14:50:38 +0200 Subject: [PATCH] Fix for bug that resulted in duplicate processes By cleaning up dead child processes when spawning the child process on the new supervisor. --- lib/horde/dynamic_supervisor_impl.ex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/horde/dynamic_supervisor_impl.ex b/lib/horde/dynamic_supervisor_impl.ex index e5e6af9..67e4116 100644 --- a/lib/horde/dynamic_supervisor_impl.ex +++ b/lib/horde/dynamic_supervisor_impl.ex @@ -426,6 +426,10 @@ defmodule Horde.DynamicSupervisorImpl do case current_member do %{status: :dead} -> + if state.supervisor_options[:process_redistribution] == :passive do + GenServer.cast(self(), {:disown_child_process, child_spec.id}) + end + {_response, state} = add_child(randomize_child_id(child_spec), state) state