handle_info stopped crashing if no match?

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

handle_info stopped crashing if no match?

Vans S
Something weird is going on, I am on the latest Erlang release from GitHub, 20.2, and my gen_servers stopped crashing?

If I send a message to a gen_server and handle_info does not match the message, the message is ignored now?
If this is the case, how to disable this behavior and go back to the fault tolerant stable way?

If I want to make a catch-all for handle_info I will explicitly code that, if an unknown message comes to a gen_server this is
a bug in my logic/code and I need to crash hard so I can fix it.  I am getting inconsistent states and hidden bugs after
upgrading to 20.2.

If I made a mistake here and Erlang still crashing if handle_info cannot match a message, excuse me and I 
will dig deeper to what the problem can be.

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

Re: handle_info stopped crashing if no match?

Fred Hebert-2
On 02/24, Vans S wrote:

>Something weird is going on, I am on the latest Erlang release from GitHub, 20.2, and my gen_servers stopped crashing?
>
>If I send a message to a gen_server and handle_info does not match the message, the message is ignored now?
>If this is the case, how to disable this behavior and go back to the fault tolerant stable way?
>
>If I want to make a catch-all for handle_info I will explicitly code that, if an unknown message comes to a gen_server this is
>a bug in my logic/code and I need to crash hard so I can fix it.  I am getting inconsistent states and hidden bugs after
>upgrading to 20.2.
>
>If I made a mistake here and Erlang still crashing if handle_info cannot match a message, excuse me and I 
>will dig deeper to what the problem can be.

This may be on purpose if this is a case where handle_info is not there
at all (I personally disagree with this decision)  You can see the
discussions leading up to it at: https://github.com/erlang/otp/pull/1346

If what you have is a handle_info function but you mean there's an
implicit catch-all clause, then I have never seen that taking place.
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: handle_info stopped crashing if no match?

Max Lapshin-2
As for me, we try to _never_  put such code:

handle_info(_UnknownMsg, State) ->
   {noreply, State}.


Such clause catches not only _UnknownMsg, but also  changed State after hot reload and may cost several hours of debugging.

This is what we try to put in code:

handle_info(_UnknownMsg, #state{} = State) ->
  {noreply, State}.



If record #state{} changes, all processes should not live with old state.


But this is of course a source of error.  More safe is to write:

handle_info(UnknownMsg, #state{} = State) ->
  {stop, {unknown, UnknownMsg}, State}.



You should not ever receive unknown messages in your system. Once you start adding silent catch-all clause in your system, it will be hard
to stop and hard to find where error begins and ends.


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

Re: handle_info stopped crashing if no match?

Max Lapshin-2

"

bjorng on Feb 17, 2017 

Contributor

Use =:= instead of ==."



Why using =:= is better? 


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

Re: handle_info stopped crashing if no match?

Fred Hebert-2
In reply to this post by Max Lapshin-2
On 02/25, Max Lapshin wrote:
>
>You should not ever receive unknown messages in your system. Once you start
>adding silent catch-all clause in your system, it will be hard
>to stop and hard to find where error begins and ends.

The one exception that comes to mind is a system where each worker is
part of a broader distributed system where unknown notifications may be
coming through from other nodes where a code upgrade has taken place
before the current one.

In such cases, an approach based on logging & keeping on going may prove
essential to the stability of the overall system.

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

Re: handle_info stopped crashing if no match?

Max Lapshin-2
Got it, ok.


On Sun, Feb 25, 2018 at 5:29 AM, Fred Hebert <[hidden email]> wrote:
On 02/25, Max Lapshin wrote:

You should not ever receive unknown messages in your system. Once you start
adding silent catch-all clause in your system, it will be hard
to stop and hard to find where error begins and ends.

The one exception that comes to mind is a system where each worker is part of a broader distributed system where unknown notifications may be coming through from other nodes where a code upgrade has taken place before the current one.

In such cases, an approach based on logging & keeping on going may prove essential to the stability of the overall system.

Regards,
Fred.


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

Re: handle_info stopped crashing if no match?

Mikael Pettersson-5
In reply to this post by Max Lapshin-2
On Sun, Feb 25, 2018 at 1:01 AM, Max Lapshin <[hidden email]> wrote:

> Btw,   https://github.com/erlang/otp/pull/1346#discussion_r101742522
>
> "
>
> bjorng on Feb 17, 2017
>
> Contributor
>
> Use =:= instead of ==."
>
>
>
> Why using =:= is better?

=:= is exact equality as used in pattern-matching, == is "value
equality" where in addition integers compare equal to same-valued
floats.

Generally use the exact operations =:= and =/= unless you're certain
you want the variants with implicit numerical conversions.  There's
also a slight performance benefit to the exact operations.
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: handle_info stopped crashing if no match?

Anthony Ramine-4
There is absolutely no such performance benefit if at least one of the operands is known to not be an integer, the compiler optimises that.

> Le 25 févr. 2018 à 11:38, Mikael Pettersson <[hidden email]> a écrit :
>
> Generally use the exact operations =:= and =/= unless you're certain
> you want the variants with implicit numerical conversions.  There's
> also a slight performance benefit to the exact operations.

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

Re: handle_info stopped crashing if no match?

Steve Strong
Unless you’re comparing binaries for equality, in which case =:= is vastly more performant than ==, although I believe this has been fixed in a recent pull request...

Sent from my iPhone

> On 25 Feb 2018, at 15:23, Anthony Ramine <[hidden email]> wrote:
>
> There is absolutely no such performance benefit if at least one of the operands is known to not be an integer, the compiler optimises that.
>
>> Le 25 févr. 2018 à 11:38, Mikael Pettersson <[hidden email]> a écrit :
>>
>> Generally use the exact operations =:= and =/= unless you're certain
>> you want the variants with implicit numerical conversions.  There's
>> also a slight performance benefit to the exact operations.
>
> _______________________________________________
> 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: handle_info stopped crashing if no match?

Michael Uvarov-2
Unknown messages will come if you have a call, that timeouts and you catch an error.

On Sun, 25 Feb 2018, 16:38 Steve Strong, <[hidden email]> wrote:
Unless you’re comparing binaries for equality, in which case =:= is vastly more performant than ==, although I believe this has been fixed in a recent pull request...

Sent from my iPhone

> On 25 Feb 2018, at 15:23, Anthony Ramine <[hidden email]> wrote:
>
> There is absolutely no such performance benefit if at least one of the operands is known to not be an integer, the compiler optimises that.
>
>> Le 25 févr. 2018 à 11:38, Mikael Pettersson <[hidden email]> a écrit :
>>
>> Generally use the exact operations =:= and =/= unless you're certain
>> you want the variants with implicit numerical conversions.  There's
>> also a slight performance benefit to the exact operations.
>
> _______________________________________________
> 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

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

Re: handle_info stopped crashing if no match?

Vans S
Is there anyway to disable this behavior (the handle_info if not defined producing a warning). I consider it a regression at this point because it has actually wasted a few hours of my time already debugging running large systems with many components as new features were being added.


On Sunday, February 25, 2018 12:06 PM, Michael Uvarov <[hidden email]> wrote:


Unknown messages will come if you have a call, that timeouts and you catch an error.

On Sun, 25 Feb 2018, 16:38 Steve Strong, <[hidden email]> wrote:
Unless you’re comparing binaries for equality, in which case =:= is vastly more performant than ==, although I believe this has been fixed in a recent pull request...

Sent from my iPhone

> On 25 Feb 2018, at 15:23, Anthony Ramine <[hidden email]> wrote:
>
> There is absolutely no such performance benefit if at least one of the operands is known to not be an integer, the compiler optimises that.
>
>> Le 25 févr. 2018 à 11:38, Mikael Pettersson <[hidden email]> a écrit :
>>
>> Generally use the exact operations =:= and =/= unless you're certain
>> you want the variants with implicit numerical conversions.  There's
>> also a slight performance benefit to the exact operations.
>
> _______________________________________________
> 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
_______________________________________________
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