summaryrefslogtreecommitdiff
path: root/lib/diameter
diff options
context:
space:
mode:
authorAnders Svensson <anders@erlang.org>2020-02-20 12:24:15 +0100
committerAnders Svensson <anders@erlang.org>2020-02-20 13:14:06 +0100
commit6b6785c4373b8f302220570f3f8aa5e0dff7e933 (patch)
treebe4df72fe4f4ffcd6c0689cd7be7999f6edd2107 /lib/diameter
parentb1a7438e06316a3da06b585f7ec9a17472feb87a (diff)
downloaderlang-6b6785c4373b8f302220570f3f8aa5e0dff7e933.tar.gz
Tweak traffic counters for remote request handler processes
Redo the solution in commit d1838e6b to spawn a process on the transport node instead of banging the diameter_peer_fsm process. Maybe a little more costly, but banging introduces an upgrade problem: nodes on which transport is terminated have to be upgraded before nodes handling request or else the receiving diameter_peer_fsm process can crash on an unexpected message, taking a peer connection with it. Not an odious requirement as long as transport/handler nodes are distinct, but it still has to be documented wheres spawning into an existing function just works. In the case that there isn't a clean transport/handler division, the solution would be to stop and then start all nodes in the cluster, or just accept that peer connections can be lost, but not having a clear division is probably questionable use of remote handlers: the point is to be able to move request handling from a node that terminates transport to another node with less to do, not to another node that terminates transport. This also has the advantage of counters not being dropped if the fsm process goes down. The handler process increments them independently of the fsm process just as if it had been on the transport node. Configure {traffic_counters, false} to skip counters altogether, which is the cheapest solution.
Diffstat (limited to 'lib/diameter')
-rw-r--r--lib/diameter/src/base/diameter_peer_fsm.erl5
-rw-r--r--lib/diameter/src/base/diameter_traffic.erl11
2 files changed, 6 insertions, 10 deletions
diff --git a/lib/diameter/src/base/diameter_peer_fsm.erl b/lib/diameter/src/base/diameter_peer_fsm.erl
index 6ea8fbd571..b86dcaf923 100644
--- a/lib/diameter/src/base/diameter_peer_fsm.erl
+++ b/lib/diameter/src/base/diameter_peer_fsm.erl
@@ -341,11 +341,6 @@ handle_cast(_, State) ->
%% handle_info/1
-%% Counter increment from a remote handler process.
-handle_info({incr, Counter}, State) ->
- diameter_stats:incr(Counter, self(), 1),
- {noreply, State};
-
handle_info(T, #state{} = State) ->
try transition(T, State) of
ok ->
diff --git a/lib/diameter/src/base/diameter_traffic.erl b/lib/diameter/src/base/diameter_traffic.erl
index 3a85b7c4d7..76f2420c7b 100644
--- a/lib/diameter/src/base/diameter_traffic.erl
+++ b/lib/diameter/src/base/diameter_traffic.erl
@@ -1244,12 +1244,13 @@ is_result(RC, true, _) ->
%% incr/2
-incr(TPid, Counter)
- when node(TPid) == node() ->
- diameter_stats:incr(Counter, TPid, 1);
-
incr(TPid, Counter) ->
- TPid ! {incr, Counter}.
+ Node = node(TPid),
+ if Node == node() ->
+ diameter_stats:incr(Counter, TPid, 1);
+ true ->
+ spawn(Node, diameter_stats, incr, [Counter, TPid, 1])
+ end.
%% rcc/1