flame icon indicating copy to clipboard operation
flame copied to clipboard

Handle Already Dropped Caller

Open samharnack opened this issue 1 year ago • 4 comments

I periodically get a match error when a caller is dropped that doesn't exist in Terminator.calls. I'm not sure how to test for this or even how it gets in this state in the first place. Does anyone have any insight into this?

samharnack avatar Oct 05 '24 16:10 samharnack

Can you share a specific match error, or the line that fails? We are matching on state.calls in a couple places, so I just want to be sure before I review. Thanks!

chrismccord avatar Oct 08 '24 02:10 chrismccord

It was matching against an empty map %{}.

I don't have the exact error anymore; I'll see if I can get it to happen again and provide the stack trace.

This could also be added as another case here: https://github.com/phoenixframework/flame/blob/main/lib/flame/terminator.ex#L202

I don't know if its related, but I'm also seeing this error occasionally:

** (ErlangError) Erlang error: :timeout

lib/flame/runner.ex:143 FLAME.Runner.call/4
lib/flame/pool.ex:250 anonymous fn/6 in FLAME.Pool.do_call/4
lib/flame/pool.ex:326 FLAME.Pool.caller_checkout!/5
lib/task/supervised.ex:101 Task.Supervised.invoke_mfa/2
lib/task/supervised.ex:36 Task.Supervised.reply/4

samharnack avatar Oct 08 '24 14:10 samharnack

Finally got the exception 🎉

** (MatchError) no match of right hand side value: %{
#Reference<70218.4250035323.1243086849.196657> => %FLAME.Terminator.Caller{from_pid: #PID<70218.4631.0>, timer: #Reference<70218.4250035323.1243086849.196658>, placed_child_ref: nil, placed_caller_ref: nil, link?: false},
#Reference<70218.4250035323.1243086849.196670> => %FLAME.Terminator.Caller{from_pid: #PID<70218.4632.0>, timer: #Reference<70218.4250035323.1243086849.196671>, placed_child_ref: nil, placed_caller_ref: nil, link?: false},
#Reference<70218.4250035323.1243086849.196712> => %FLAME.Terminator.Caller{from_pid: #PID<70218.4636.0>, timer: #Reference<70218.4250035323.1243086849.196713>, placed_child_ref: nil, placed_caller_ref: nil, link?: false},
#Reference<70218.4250035323.1243086849.196880> => %FLAME.Terminator.Caller{from_pid: #PID<70218.4646.0>, timer: #Reference<70218.4250035323.1243086849.196881>, placed_child_ref: nil, placed_caller_ref: nil, link?: false},
#Reference<70218.4250035323.1243086849.196901> => %FLAME.Terminator.Caller{from_pid: #PID<70218.4650.0>, timer: #Reference<70218.4250035323.1243086849.196902>, placed_child_ref: nil, placed_caller_ref: nil, link?: false},
#Reference<70218.4250035323.1243086849.196908> => %FLAME.Terminator.Caller{from_pid: #PID<70218.4651.0>, timer: #Reference<70218.4250035323.1243086849.196909>, placed_child_ref: nil, placed_caller_ref: nil, link?: false},
#Reference<70218.4250035323.1243086849.196919> => %FLAME.Terminator.Caller{from_pid: #PID<70218.4652.0>, timer: #Reference<70218.4250035323.1243086849.196920>, placed_child_ref: nil, placed_caller_ref: nil, link?: false},
#Reference<70218.4250035323.1243086849.196941> => %FLAME.Terminator.Caller{from_pid: #PID<70218.4661.0>, timer: #Reference<70218.4250035323.1243086849.196942>, placed_child_ref: nil, placed_caller_ref: nil, link?: false},
#Reference<70218.4250035323.1243086853.194886> => %FLAME.Terminator.Caller{from_pid: #PID<70218.4656.0>, timer: #Reference<70218.4250035323.1243086853.194887>, placed_child_ref: nil, placed_caller_ref: nil, link?: false},
#Reference<70218.4250035323.1243086853.194899> => %FLAME.Terminator.Caller{from_pid: #PID<70218.4657.0>, timer: #Reference<70218.4250035323.1243086853.194900>, placed_child_ref: nil, placed_caller_ref: nil, link?: false}
}


lib/flame/terminator.ex:333 FLAME.Terminator.drop_caller/2
lib/flame/terminator.ex:203 FLAME.Terminator.handle_info/2
gen_server.erl:2173 :gen_server.try_handle_info/3
gen_server.erl:2261 :gen_server.handle_msg/6
proc_lib.erl:329 :proc_lib.init_p_do_apply/3

samharnack avatar Nov 19 '24 18:11 samharnack

It may be better to make sure we don't call drop_caller if it has been dropped already, rather than making every call now potentially "soft"?

josevalim avatar Jan 27 '25 13:01 josevalim