Procházet zdrojové kódy

chore(eviction): phase out session persistence concerns

Andrew Mayorov před 2 roky
rodič
revize
3ba6d34511

+ 1 - 1
apps/emqx_eviction_agent/src/emqx_eviction_agent.app.src

@@ -1,6 +1,6 @@
 {application, emqx_eviction_agent, [
     {description, "EMQX Eviction Agent"},
-    {vsn, "5.0.1"},
+    {vsn, "5.1.0"},
     {registered, [
         emqx_eviction_agent_sup,
         emqx_eviction_agent,

+ 2 - 10
apps/emqx_eviction_agent/src/emqx_eviction_agent_channel.erl

@@ -165,9 +165,8 @@ handle_cast(Msg, Channel) ->
     ?SLOG(error, #{msg => "unexpected_cast", cast => Msg}),
     {noreply, Channel}.
 
-terminate(Reason, #{conninfo := ConnInfo, clientinfo := ClientInfo, session := Session} = Channel) ->
+terminate(Reason, #{clientinfo := ClientInfo, session := Session} = Channel) ->
     ok = cancel_expiry_timer(Channel),
-    (Reason =:= expired) andalso emqx_persistent_session:persist(ClientInfo, ConnInfo, Session),
     emqx_session:terminate(ClientInfo, Reason, Session).
 
 code_change(_OldVsn, Channel, _Extra) ->
@@ -205,10 +204,7 @@ handle_deliver(
     Delivers1 = emqx_channel:maybe_nack(Delivers),
     Delivers2 = emqx_session:ignore_local(ClientInfo, Delivers1, ClientId, Session),
     NSession = emqx_session:enqueue(ClientInfo, Delivers2, Session),
-    NChannel = persist(NSession, Channel),
-    %% We consider queued/dropped messages as delivered since they are now in the session state.
-    emqx_channel:maybe_mark_as_delivered(Session, Delivers),
-    NChannel.
+    Channel#{session := NSession}.
 
 cancel_expiry_timer(#{expiry_timer := TRef}) when is_reference(TRef) ->
     _ = erlang:cancel_timer(TRef),
@@ -334,10 +330,6 @@ channel(ConnInfo, ClientInfo) ->
         pendings => []
     }.
 
-persist(Session, #{clientinfo := ClientInfo, conninfo := ConnInfo} = Channel) ->
-    Session1 = emqx_persistent_session:persist(ClientInfo, ConnInfo, Session),
-    Channel#{session => Session1}.
-
 info(Channel) ->
     #{
         conninfo => maps:get(conninfo, Channel, undefined),

+ 0 - 3
apps/emqx_eviction_agent/test/emqx_eviction_agent_channel_SUITE.erl

@@ -36,9 +36,6 @@ init_per_testcase(_TestCase, Config) ->
     Config.
 
 end_per_testcase(t_persistence, Config) ->
-    emqx_config:put([persistent_session_store, enabled], false),
-    emqx_persistent_session:init_db_backend(),
-    ?assertNot(emqx_persistent_session:is_store_enabled()),
     Config;
 end_per_testcase(_TestCase, _Config) ->
     ok.