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

This commit is contained in:
ieQu1 2024-04-16 11:51:53 +02:00
parent 93bb840365
commit 197a4c30be
No known key found for this signature in database
GPG Key ID: 488654DF3FED6FDE
2 changed files with 10 additions and 3 deletions

View File

@ -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)
%%--------------------------------------------------------------------

View File

@ -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,