@@ -584,14 +584,17 @@ locate_endpoints({Type, Name}, Strategy, Locators) ->
584
584
% % our book keeping for that endpoint. Black-list it, and
585
585
% % adjust a backoff timer so that we wait a while before
586
586
% % trying this endpoint again.
587
+
588
+ -spec fail_endpoint (ip_addr (), term (), proto_id (), # state {}) -> # state {}.
587
589
fail_endpoint (Addr , Reason , ProtocolId , State ) ->
588
590
% % update the stats module
589
- Stat = {conn_error , Reason },
591
+ Err = reason_to_atom (Reason ),
592
+ Stat = {conn_error , Err },
590
593
riak_core_connection_mgr_stats :update (Stat , Addr , ProtocolId ),
591
594
% % update the endpoint
592
595
Fun = fun (EP = # ep {backoff_delay = Backoff , failures = Failures }) ->
593
596
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 ),
595
598
nb_failures = EP # ep .nb_failures + 1 ,
596
599
backoff_delay = increase_backoff (Backoff ),
597
600
last_fail_time = os :timestamp (),
@@ -600,6 +603,18 @@ fail_endpoint(Addr, Reason, ProtocolId, State) ->
600
603
end ,
601
604
update_endpoint (Addr , Fun , State ).
602
605
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
+
603
618
connect_endpoint (Addr , State ) ->
604
619
update_endpoint (Addr , fun (EP ) ->
605
620
EP # ep {is_black_listed = false ,
0 commit comments