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

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
jaybe78
Hello, I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter). The diffic...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
widianto
I think I’ve found a small improvement I could contribute to &lt;%= web_namespace %&gt;.CoreComponents (installer/templates/phx_web/compo...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
aseigo
ICal is a library for interacting with iCalendar data. It parses iCalendars into typed Elixir structs via ICal.from_ics, and can prepare ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews