Преглед изворни кода

fix(sessds): Strip unneccessary data from the durable session state

ieQu1 пре 1 година
родитељ
комит
197a4c30be

+ 7 - 2
apps/emqx/src/emqx_persistent_session_ds.erl

@@ -786,7 +786,7 @@ session_open(SessionId, ClientInfo, NewConnInfo, MaybeWillMsg) ->
                         maps:get(peername, NewConnInfo), S2
                     ),
                     S4 = emqx_persistent_session_ds_state:set_will_message(MaybeWillMsg, S3),
-                    S5 = emqx_persistent_session_ds_state:set_clientinfo(ClientInfo, S4),
+                    S5 = set_clientinfo(ClientInfo, S4),
                     S = emqx_persistent_session_ds_state:commit(S5),
                     Inflight = emqx_persistent_session_ds_inflight:new(
                         receive_maximum(NewConnInfo)
@@ -833,7 +833,7 @@ session_ensure_new(Id, ClientInfo, ConnInfo, MaybeWillMsg, Conf) ->
         ]
     ),
     S5 = emqx_persistent_session_ds_state:set_will_message(MaybeWillMsg, S4),
-    S6 = emqx_persistent_session_ds_state:set_clientinfo(ClientInfo, S5),
+    S6 = set_clientinfo(ClientInfo, S5),
     S = emqx_persistent_session_ds_state:commit(S6),
     #{
         id => Id,
@@ -864,6 +864,11 @@ session_drop(ID, Reason) ->
 now_ms() ->
     erlang:system_time(millisecond).
 
+set_clientinfo(ClientInfo0, S) ->
+    %% Remove unnecessary fields from the clientinfo:
+    ClientInfo = maps:without([cn, dn, auth_result], ClientInfo0),
+    emqx_persistent_session_ds_state:set_clientinfo(ClientInfo, S).
+
 %%--------------------------------------------------------------------
 %% RPC targets (v1)
 %%--------------------------------------------------------------------

+ 3 - 1
apps/emqx_management/src/emqx_mgmt_api_clients.erl

@@ -1763,7 +1763,9 @@ format_persistent_session_info(ClientId, PSInfo0) ->
         connected_at => CreatedAt,
         ip_address => IpAddress,
         is_persistent => true,
-        port => Port
+        port => Port,
+        heap_size => 0,
+        mqueue_len => 0
     },
     PSInfo = lists:foldl(
         fun result_format_time_fun/2,