Comments (8)
@derekkraan I am sure that I am doing something wrong here, but this issue/my mistake is my blocking my team in production.
from horde.
This could be related maybe? #219
from horde.
Hi, can you put your failing test in a test in a branch and link it here?
from horde.
I will put it in a branch within a second.
It seems to be an issue of names vs pids. If change the test to never refer to the pid for the DynamicSupervisor or Horde.DynamicSupervisor, but instead to the name, it passes.
defmodule BasicGenServer do
use GenServer
def start_link(arg) do
GenServer.start_link(__MODULE__, arg)
end
@impl true
def init(init_arg) do
{:ok, init_arg}
end
@impl true
def handle_info(:stop_normal, state) do
{:stop, :normal, state}
end
end
{:ok, _sup} = DynamicSupervisor.start_link([strategy: :one_for_one, name: TestSup, automatic_shutdown: :never])
{:ok, child1} = DynamicSupervisor.start_child(TestSup, %{id: :child1, start: {BasicGenServer, :start_link, [0]}})
{:ok, child2} = DynamicSupervisor.start_child(TestSup, %{id: :child2, start: {BasicGenServer, :start_link, [0]}})
{:ok, child3} = DynamicSupervisor.start_child(TestSup, %{id: :child3, start: {BasicGenServer, :start_link, [0]}})
Process.exit(child1, :kill)
IO.puts("Sent :stop_normal message to child of TestSup")
children = DynamicSupervisor.which_children(TestSup)
if Enum.count(children, fn {_id, _pid, _type, mod} -> [BasicGenServer] == mod end) != 3 do
raise "Not 3 BasicGenServers for TestSup"
else
IO.inspect(children)
IO.puts("3 children for TestSup!")
end
{:ok, _sup} = Horde.DynamicSupervisor.start_link([strategy: :one_for_one, name: HordeTestSup, automatic_shutdown: :never])
{:ok, child1} = Horde.DynamicSupervisor.start_child(HordeTestSup, %{id: :child1, start: {BasicGenServer, :start_link, [0]}})
{:ok, child2} = Horde.DynamicSupervisor.start_child(HordeTestSup, %{id: :child2, start: {BasicGenServer, :start_link, [0]}})
{:ok, child3} = Horde.DynamicSupervisor.start_child(HordeTestSup, %{id: :child3, start: {BasicGenServer, :start_link, [0]}})
Process.exit(child1, :kill)
IO.puts("Sent :stop_normal message to child of TestHordeSup")
children = Horde.DynamicSupervisor.which_children(HordeTestSup)
if Enum.count(children, fn {_id, _pid, _type, mod} -> [BasicGenServer] == mod end) != 3 do
raise "Not 3 BasicGenServers for TestHordeSup"
else
IO.puts("3 children for TestHordeSup!")
end
Will add this to branch as well.
from horde.
from horde.
Could our discussion on our ElixirForum here be relevant? https://elixirforum.com/t/horde-dynamicsupervisor-terminate-child-is-not-working/61558/3?u=gavid
from horde.
I have added the equivalent tests to the branch. Please let me know if you see anything you need improved or if certain tests are meant to fail e.g. per our discussion linked in previous message
from horde.
Hi, I have looked at your tests and I understand now what the issue is. Horde.DynamicSupervisor only supports being called by name, not by the pid returned by Horde.DynamicSupervisor.start_link/3
.
The reason for this is that Horde.DynamicSupervisor.start_link/3
starts a Supervisor with a number of children, one of them being the Horde.DynamicSupervisorImpl
, which is where the name is registered to. The pid
returned is really only meant to be used by the supervision tree. Usually you will start Horde.DynamicSupervisor
in a supervision tree, and never see the pid
.
So when you use the pid returned to start a new child, you are not running that child under Horde.DynamicSupervisor
, but under a regular supervisor in the local supervision tree.
It's not possible to resolve this inconsistency without a major rewrite of the lib.
I hope this clarifies things. If you have any suggestions on how to improve the docs to make this more clear, I would consider a PR for that.
from horde.
Related Issues (20)
- DynamicSupervisor.start_child hangs on infinite timeout HOT 3
- Is it possible to start a Horde dynamic supervisor with a registered name? HOT 2
- match error when stopping a process HOT 1
- Stopping Child via Horde.DynamicSupervisor.terminate_child with via_tuple HOT 1
- Occasional Horde Registry Lookup Misses HOT 2
- GenServer.cast cant find process via {:via, Horde.Registry, ...} HOT 6
- race condition in name conflict in same registry process results in all processes losing HOT 20
- Default random node distribution strategy HOT 5
- Match error while doing process handoff in dynamic supervisor
- Use new PartitionSupervisor
- Timeouts and Crashes in the Cluster HOT 2
- Disappearing values from Horde.Registry after spawning more than two nodes. HOT 2
- Why we need to handle {:error, {:already_started, pid}} ? HOT 4
- SayHello GenServer never (re)started on `count3` node?
- uniform_random_distribution.ex not in deps 8.7 HOT 1
- Old child specs remain in Supervisor CRDT after process handoff
- Registry.lookup doesn't always return new item that was just registered HOT 13
- Example of How to Start Children like a Regular Supervisor
- Include horde_process in the main repo HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from horde.