-
Notifications
You must be signed in to change notification settings - Fork 129
Description
Hey all!
I noticed that when calling Phoenix.Tracker.graceful_permdown/1 shards are being restarted on the Tracker that we're currently in the process of shutting down.
Looking through the source code I think the problem ist that when we are passing the shards to the Supervisor, the child_spec field :restart defaults to :permanent which according to the Supervisor docs
means
:permanent- the child process is always restarted.
However, I think we actually want this:
:transient- the child process is restarted only if it terminates abnormally, i.e., with an exit reason other than:normal,:shutdown, or{:shutdown, term}.
as in the Shard graceful_permdown callback we are trying to gracefully stop the Shard GenServer
def handle_call(:graceful_permdown, _from, state) do
broadcast_from(state, self(), {:pub, :graceful_permdown, Replica.ref(state.replica)})
{:stop, :normal, :ok, state}
end
Returning
{:stop, reason, reply, new_state}stops the loop
https://hexdocs.pm/elixir/1.18.2/GenServer.html#c:handle_call/3
Explicitly specifying restart: :transient in https://github.com/phoenixframework/phoenix_pubsub/blob/main/lib/phoenix/tracker.ex#L328 seems to fix the issue.
Does that make sense? If yes, take a look at #195