Skip to content

Commit 5843aad

Browse files
committed
Merge pull request #717 from basho/merge/2.0-into-2.1/memory-leak-in-rc_conn_mgr_stats
Merge branch `2.0` into `2.1` Reviewed-by: JeetKunDoug
2 parents eb979ee + ead3ec5 commit 5843aad

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/riak_core_connection_mgr.erl

+17-2
Original file line numberDiff line numberDiff line change
@@ -584,14 +584,17 @@ locate_endpoints({Type, Name}, Strategy, Locators) ->
584584
%% our book keeping for that endpoint. Black-list it, and
585585
%% adjust a backoff timer so that we wait a while before
586586
%% trying this endpoint again.
587+
588+
-spec fail_endpoint(ip_addr(), term(), proto_id(), #state{}) -> #state{}.
587589
fail_endpoint(Addr, Reason, ProtocolId, State) ->
588590
%% update the stats module
589-
Stat = {conn_error, Reason},
591+
Err = reason_to_atom(Reason),
592+
Stat = {conn_error, Err},
590593
riak_core_connection_mgr_stats:update(Stat, Addr, ProtocolId),
591594
%% update the endpoint
592595
Fun = fun(EP=#ep{backoff_delay = Backoff, failures = Failures}) ->
593596
erlang:send_after(Backoff, self(), {backoff_timer, Addr}),
594-
EP#ep{failures = orddict:update_counter(Reason, 1, Failures),
597+
EP#ep{failures = orddict:update_counter(Err, 1, Failures),
595598
nb_failures = EP#ep.nb_failures + 1,
596599
backoff_delay = increase_backoff(Backoff),
597600
last_fail_time = os:timestamp(),
@@ -600,6 +603,18 @@ fail_endpoint(Addr, Reason, ProtocolId, State) ->
600603
end,
601604
update_endpoint(Addr, Fun, State).
602605

606+
%% Attempt to extract atom from an error reason.
607+
608+
-spec reason_to_atom(term()) -> atom().
609+
reason_to_atom({{Err, _Val}, _Stack}) when is_atom(Err) ->
610+
Err;
611+
reason_to_atom({Err, _Stack}) when is_atom(Err) ->
612+
Err;
613+
reason_to_atom(Reason) when is_atom(Reason) ->
614+
Reason;
615+
reason_to_atom(_Reason) ->
616+
unknown_reason.
617+
603618
connect_endpoint(Addr, State) ->
604619
update_endpoint(Addr, fun(EP) ->
605620
EP#ep{is_black_listed = false,

0 commit comments

Comments
 (0)