Freeze gen_server

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Freeze gen_server

Roberto Ostinelli
Dear list,
I realize how this sounds but: is there a way to temporarily "freeze" a gen_server, so that messages sent to it are not received and its message box stays intact until it is "unfrozen"?

What I am trying to achieve: I need to provide a "global lock" mechanism for a specific use case related to cluster conflict resolution. While that conflict resolution is ongoing, I want to ensure that no other changes happen anywhere else.

Any ideas?

Thanks,
r.

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Fwd: Freeze gen_server

Gleb Vinogradov
Hi, Roberto.

Have you tried sys:suspend/1, sys:resume/1 ?

Gleb.

2016-03-29 19:44 GMT+06:00 Roberto Ostinelli <[hidden email]>:
Dear list,
I realize how this sounds but: is there a way to temporarily "freeze" a gen_server, so that messages sent to it are not received and its message box stays intact until it is "unfrozen"?

What I am trying to achieve: I need to provide a "global lock" mechanism for a specific use case related to cluster conflict resolution. While that conflict resolution is ongoing, I want to ensure that no other changes happen anywhere else.

Any ideas?

Thanks,
r.

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions




_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Freeze gen_server

Raimo Niskanen-2
On Tue, Mar 29, 2016 at 07:51:14PM +0600, Gleb Vinogradov wrote:
> Hi, Roberto.
>
> Have you tried sys:suspend/1, sys:resume/1 ?

That is used by when upgrading an application.  First all servers belonging
to the application is suspended using sys:suspend/1, then all modules
are upgraded, then the code upgrade function is called on all servers
and lastly the servers are resumed using sys:resume/1.

While suspended the servers will still respond to system messages,
otherwise sys:resume/1 would not work.  That is done using a selective
receive for {system,From,Msg} and {'EXIT',Parent,Reason} so an application
can still be stopped while servers are suspended.

>
> Gleb.
>
> 2016-03-29 19:44 GMT+06:00 Roberto Ostinelli <[hidden email]>:
>
> > Dear list,
> > I realize how this sounds but: is there a way to temporarily "freeze" a
> > gen_server, so that messages sent to it are not received and its message
> > box stays intact until it is "unfrozen"?
> >
> > What I am trying to achieve: I need to provide a "global lock" mechanism
> > for a specific use case related to cluster conflict resolution. While that
> > conflict resolution is ongoing, I want to ensure that no other changes
> > happen anywhere else.
> >
> > Any ideas?
> >
> > Thanks,
> > r.
> >
> > _______________________________________________
> > erlang-questions mailing list
> > [hidden email]
> > http://erlang.org/mailman/listinfo/erlang-questions
> >
> >

> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions


--

/ Raimo Niskanen, Erlang/OTP, Ericsson AB
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Freeze gen_server

Roberto Ostinelli
Thank you all. These are extremely helpful and can't thank you enough.

For anyone interested, I needed to ensure that during Syn's MNESIA auto-conflict resolution I would not allow other processes to modify the MNESIA tables entries before the resolution is over.
I've therefore used the suspend / resume schema, this can be seen here:

Again, thank you Gleb, Ulf and Raimo for the great answers.

Best,
r.




_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions