Просмотр исходного кода

Merge pull request #14183 from thalesmg/20241107-r583-mgmt-api-kick-ds

fix(clients mgmt api): handle potential race condition when formatting/fetching kicked clients
Thales Macedo Garitezi 1 год назад
Родитель
Сommit
00d65892ab
1 измененных файлов с 7 добавлено и 1 удалено
  1. 7 1
      apps/emqx_management/src/emqx_mgmt_api_clients.erl

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

@@ -1872,7 +1872,13 @@ format_channel_info(WhichNode, {_, ClientInfo0, ClientStats}, Opts) ->
         )
     );
 format_channel_info(undefined, {ClientId, PSInfo0 = #{}}, _Opts) ->
-    format_persistent_session_info(ClientId, PSInfo0).
+    format_persistent_session_info(ClientId, PSInfo0);
+format_channel_info(undefined, {ClientId, undefined = _PSInfo}, _Opts) ->
+    %% Durable session missing its metadata: possibly a race condition, such as the client
+    %% being kicked while the API is enumerating clients.  There's nothing much to do, we
+    %% just return an almost empty map to avoid crashing this function.  The client may
+    %% just retry listing in such cases.
+    #{clientid => ClientId}.
 
 format_persistent_session_info(
     _ClientId,