From 47bc747323ed8279b9cd0cf1e7bfc321bfdb10d2 Mon Sep 17 00:00:00 2001 From: Andrew Mayorov Date: Fri, 1 Dec 2023 19:35:05 +0300 Subject: [PATCH] fix(sessds): drop everything related to session on CleanStart --- apps/emqx/src/emqx_persistent_session_ds.erl | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/emqx/src/emqx_persistent_session_ds.erl b/apps/emqx/src/emqx_persistent_session_ds.erl index bedd72a16..376081a70 100644 --- a/apps/emqx/src/emqx_persistent_session_ds.erl +++ b/apps/emqx/src/emqx_persistent_session_ds.erl @@ -646,7 +646,7 @@ session_open(SessionId, NewConnInfo) -> session(). session_ensure_new(SessionId, ConnInfo) -> transaction(fun() -> - ok = session_drop_subscriptions(SessionId), + ok = session_drop_records(SessionId), Session = export_session(session_create(SessionId, ConnInfo)), Session#{ subscriptions => subs_new(), @@ -693,13 +693,17 @@ session_set_last_alive_at(SessionRecord0, LastAliveAt) -> -spec session_drop(id()) -> ok. session_drop(DSSessionId) -> transaction(fun() -> - ok = session_drop_subscriptions(DSSessionId), - ok = session_drop_pubranges(DSSessionId), - ok = session_drop_offsets(DSSessionId), - ok = session_drop_streams(DSSessionId), + ok = session_drop_records(DSSessionId), ok = mnesia:delete(?SESSION_TAB, DSSessionId, write) end). +-spec session_drop_records(id()) -> ok. +session_drop_records(DSSessionId) -> + ok = session_drop_subscriptions(DSSessionId), + ok = session_drop_pubranges(DSSessionId), + ok = session_drop_offsets(DSSessionId), + ok = session_drop_streams(DSSessionId). + -spec session_drop_subscriptions(id()) -> ok. session_drop_subscriptions(DSSessionId) -> Subscriptions = session_read_subscriptions(DSSessionId, write),