fix(ds): Destroy LTS tries when the generation is dropped

This commit is contained in:
ieQu1 2024-04-23 00:20:59 +02:00
parent 9999ccd36c
commit bcfa7b2209
No known key found for this signature in database
GPG Key ID: 488654DF3FED6FDE
2 changed files with 9 additions and 1 deletions

View File

@ -19,6 +19,7 @@
%% API: %% API:
-export([ -export([
trie_create/1, trie_create/0, trie_create/1, trie_create/0,
destroy/1,
trie_restore/2, trie_restore/2,
trie_copy_learned_paths/2, trie_copy_learned_paths/2,
topic_key/3, topic_key/3,
@ -116,6 +117,12 @@ trie_create(UserOpts) ->
trie_create() -> trie_create() ->
trie_create(#{}). trie_create(#{}).
-spec destroy(trie()) -> ok.
destroy(#trie{trie = Trie, stats = Stats}) ->
catch ets:delete(Trie),
catch ets:delete(Stats),
ok.
%% @doc Restore trie from a dump %% @doc Restore trie from a dump
-spec trie_restore(options(), [{_Key, _Val}]) -> trie(). -spec trie_restore(options(), [{_Key, _Val}]) -> trie().
trie_restore(Options, Dump) -> trie_restore(Options, Dump) ->

View File

@ -240,7 +240,8 @@ post_creation_actions(
s() s()
) -> ) ->
ok. ok.
drop(_Shard, DBHandle, GenId, CFRefs, #s{}) -> drop(_Shard, DBHandle, GenId, CFRefs, #s{trie = Trie}) ->
emqx_ds_lts:destroy(Trie),
{_, DataCF} = lists:keyfind(data_cf(GenId), 1, CFRefs), {_, DataCF} = lists:keyfind(data_cf(GenId), 1, CFRefs),
{_, TrieCF} = lists:keyfind(trie_cf(GenId), 1, CFRefs), {_, TrieCF} = lists:keyfind(trie_cf(GenId), 1, CFRefs),
ok = rocksdb:drop_column_family(DBHandle, DataCF), ok = rocksdb:drop_column_family(DBHandle, DataCF),