sysashi

sysashi

I have a gen server spawned by simple one for one supervisor, and when I return {:stop, {:shutdown, reason}, state} process remains alive, even though terminate/2 callback is called. What am I doing wrong? (if instead of returning :stop tuple I call Supervisor.terminate_child(MySupervisor, self()) process terminates as expected. How do I stop it, and what is the right way?

Showing Posts 1 to 10

idi527

idi527

Does it actually remain alive (same pid), or does it get restarted?

sysashi

sysashi OP

It remains alive and not restarted

dom

dom

terminate/2 could be hanging. If you do Process.info() after the pid tried to stop, what does the backtrace look like?

kokolegorille

kokolegorille

Is it a call or a cast? I remember having some troubles with the response tupple. Maybe try to change your return value.

There is a call return

{:stop, :normal, state, state}

There is a cast return

{:stop, :normal, state}

BTW simple_one_for_one is going to be deprecated in favor of Dynamic Supervisor. I also had syntax problem, dialyzer warning because of it. simple_one_for_one does not accept new child_spec.

sysashi

sysashi OP

looks like ```
[current_function: {:gen_server, :loop, 7},
initial_call: {:proc_lib, :init_p, 5}, status: :waiting, message_queue_len: 0,
messages: , links: [pid<0.472.0>],
dictionary: [“$initial_call”: {Manager, :init, 1},
“$ancestors”: [ManagerSupervisor,
PipelineSupervisor, MySupervisor, pid<0.456.0>]],
trap_exit: false, error_handler: :error_handler, priority: :normal,
group_leader: pid<0.455.0>, total_heap_size: 233, heap_size: 233,
stack_size: 10, reductions: 45,
garbage_collection: [max_heap_size: %{error_logger: true, kill: true, size: 0},
min_bin_vheap_size: 46422, min_heap_size: 233, fullsweep_after: 65535,
minor_gcs: 0], suspending: ]

sorry if that's poorly formatted
sysashi

sysashi OP

I have both callbacks, when I need to stop on call I do {:stop, :shutdown, reply, state} on casts I do {:stop, :shutdown, state}

Yeah, I have a lot of stuff to migrate to Dynamic Supervisor :astonished:

dom

dom

It’s not possible for a gen_server to go back to loop after terminate is called. Are you really sure terminate was called, and the process wasn’t restarted?

NobbZ

NobbZ

How was the child initialised? What’s it restart value? Permanent, temporary or transient?

sysashi

sysashi OP

I’m sorry I’ve wasted your time folks, process is being restarted (Initially I’ve checked the state of the process, and for my surprise state remained from the previous process, so I thought it’s the same one, next I checked observer to verify that pid does not change and it’s the same process, but it actually has changed and new pid was a digit different from the previous one so I did not notice at first… :persevere:)
Later I set restart to temporary and it worked as intended (as @NobbZ pointed out).

One question though, does supervisor keeps initial state of the process? Because said process being restarted with the same state I initialised the previous one.

dom

dom

It doesn’t keep state, but it uses the same start function and arguments, so if your initialization is deterministic the process will end up in the same state.

For a simple_one_for_one supervisor, the child specification defined in Module:init/1 is used, and ChildSpec must instead be an arbitrary list of terms List. The child process is then started by appending List to the existing start function arguments, that is, by calling apply(M, F, A++List), where {M,F,A} is the start function defined in the child specification.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews