feat(persistent_session): add early removal of delivered message

This commit is contained in:
Tobias Lindahl 2021-10-19 10:49:17 +02:00
parent b9b8111edb
commit 655d31726a
1 changed files with 8 additions and 1 deletions

View File

@ -345,7 +345,14 @@ mark_as_delivered(SessionID, List) ->
do_mark_as_delivered(SessionID, [{deliver, STopic, Msg}|Left]) ->
MsgID = emqx_message:id(Msg),
put_session_message({SessionID, MsgID, STopic, ?DELIVERED}),
case next_session_message({SessionID, MsgID, STopic, ?ABANDONED}) of
{SessionID, MsgID, STopic, ?UNDELIVERED} = Key ->
%% We can safely delete this entry
%% instead of marking it as delivered.
delete_session_message(Key);
_ ->
put_session_message({SessionID, MsgID, STopic, ?DELIVERED})
end,
do_mark_as_delivered(SessionID, Left);
do_mark_as_delivered(_SessionID, []) ->
ok.