<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="332487" data-post-id="332487">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="gavid" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/gavid/120/31806_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  gavid
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><a class="mention" href="/u/derekkraan" rel="nofollow">@derekkraan</a></p>
<p>I have moved the discussion back here because I can’t point this to any specific issue in the library.</p>
<p>I thought that I had a solution above, but what I was actually doing was adding children directly to the Horde.DynamicSupervisor, rather than to the correct place in the tree.</p>
<p>To clarify, this is the full minimal reproducible example:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">init_arg = fn name -&gt;
  [
    name: name,
    strategy: :one_for_one,
    distribution_strategy: Horde.UniformDistribution,
    max_restarts: 100_000,
    max_seconds: 1,
    members: :auto
  ]
end

{:ok, root_supervisor} = Horde.DynamicSupervisor.start_link(init_arg.(:root_supervisor))

for num &lt;- 1..10 do
  child_supervisor = :"child_supervisor#{num}"

  {:ok, _child_supervisor_pid} =
    Horde.DynamicSupervisor.start_child(root_supervisor, %{
      id: child_supervisor,
      start: {Horde.DynamicSupervisor, :start_link, [init_arg.(child_supervisor)]}
    })
end

IO.puts("After creation...")
IO.inspect(Horde.DynamicSupervisor.which_children(root_supervisor), pretty: true)
IO.puts("-----------")

for {id, pid, :worker, _startup_module} &lt;-
      Horde.DynamicSupervisor.which_children(root_supervisor),
    String.starts_with?(Atom.to_string(id), "child_supervisor") do
  IO.puts("Trying to terminate worker with id: #{id} and process id: #{inspect(pid)}")
  # NOTE: Switched from pid to id
  :ok = :supervisor.terminate_child(root_supervisor, id)
  :ok = :supervisor.delete_child(root_supervisor, id)
end

IO.puts("After termination...")
IO.inspect(Horde.DynamicSupervisor.which_children(root_supervisor), pretty: true)
IO.puts("-----------")
:done
</code></pre>
<p>Here is what <code>After creation...</code> printout looks like. This is not the way things should be because the workers should not exist at the part of the tree. The only exist because they were added incorrectly by using the supervisor pid and not the name.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">After creation...
[
  {:child_supervisor10, #PID&lt;0.329.0&gt;, :worker, [Horde.DynamicSupervisor]},
  {:child_supervisor9, #PID&lt;0.322.0&gt;, :worker, [Horde.DynamicSupervisor]},
  {:child_supervisor8, #PID&lt;0.315.0&gt;, :worker, [Horde.DynamicSupervisor]},
  {:child_supervisor7, #PID&lt;0.308.0&gt;, :worker, [Horde.DynamicSupervisor]},
  {:child_supervisor6, #PID&lt;0.301.0&gt;, :worker, [Horde.DynamicSupervisor]},
  {:child_supervisor5, #PID&lt;0.294.0&gt;, :worker, [Horde.DynamicSupervisor]},
  {:child_supervisor4, #PID&lt;0.287.0&gt;, :worker, [Horde.DynamicSupervisor]},
  {:child_supervisor3, #PID&lt;0.280.0&gt;, :worker, [Horde.DynamicSupervisor]},
  {:child_supervisor2, #PID&lt;0.273.0&gt;, :worker, [Horde.DynamicSupervisor]},
  {:child_supervisor1, #PID&lt;0.266.0&gt;, :worker, [Horde.DynamicSupervisor]},
  {Horde.NodeListener, #PID&lt;0.265.0&gt;, :worker, [Horde.NodeListener]},
  {:root_supervisor_telemetry_poller, #PID&lt;0.264.0&gt;, :worker,
   [:telemetry_poller]},
  {Horde.SignalShutdown, #PID&lt;0.263.0&gt;, :worker, [GenServer]},
  {:"root_supervisor.ProcessesSupervisor", #PID&lt;0.262.0&gt;, :supervisor,
   [Horde.ProcessesSupervisor]},
  {Horde.DynamicSupervisorImpl, #PID&lt;0.261.0&gt;, :worker,
   [Horde.DynamicSupervisorImpl]},
  {:"root_supervisor.Crdt", #PID&lt;0.260.0&gt;, :worker, [DeltaCrdt]}
]
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="332487" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/horde-dynamicsupervisor-terminate-child-is-not-working/61558/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-332487" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="332487"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="332488" data-post-id="332488">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="gavid" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/gavid/120/31806_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  gavid
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="gavid" data-post="12" data-topic="61558">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/gavid/48/31806_2.png" class="avatar"> gavid:</div>
<blockquote>
<p>I have moved the discussion back here because I can’t point this to any specific issue in the library.</p>
<p>I thought that I had a solution above, but what I was actually doing was adding children directly to the Horde.DynamicSupervisor, rather than to the correct place in the tree.</p>
</blockquote>
</aside>
<p>Can you see any way in which it would be possible to have Horde.DynamicSupervisor children started at runtime as children of a parent Horde.DynamicSupervisor, and have each parent and child supervisor behave correctly as expected?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="332488" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/horde-dynamicsupervisor-terminate-child-is-not-working/61558/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-332488" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="332488"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="332557" data-post-id="332557">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="gavid" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/gavid/120/31806_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  gavid
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Derek Kraan answered here: <a href="https://github.com/derekkraan/horde/pull/271" class="inline-onebox" rel="noopener nofollow ugc">added explanatory note to Horde.DynamicSupervisor by gmdorf · Pull Request #271 · elixir-horde/horde · GitHub</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="332557" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/horde-dynamicsupervisor-terminate-child-is-not-working/61558/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-332557" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="332557"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-solved cat-solved" title="Marked as solution"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>