Check pdict for dumper state at close_table

This commit is contained in:
Ulf Wiger 2022-08-02 17:07:53 +02:00
parent dfc0125800
commit b908998e6b

View File

@ -162,7 +162,6 @@
, type , type
, status , status
, on_error , on_error
, loaders = []
}). }).
-type data_tab() :: atom(). -type data_tab() :: atom().
@ -452,8 +451,13 @@ close_table(Alias, Tab) ->
error -> error ->
ok; ok;
_ -> _ ->
ok = mnesia_rocksdb_admin:prep_close(Alias, Tab), case get(mnesia_dumper_dets) of
close_table_(Alias, Tab) undefined ->
ok = mnesia_rocksdb_admin:prep_close(Alias, Tab),
close_table_(Alias, Tab);
_ ->
ok
end
end. end.
close_table_(Alias, Tab) -> close_table_(Alias, Tab) ->
@ -799,7 +803,7 @@ handle_call({create_table, Tab, Props}, _From,
handle_call({load_table, _LoadReason, Props}, {Pid,_}, handle_call({load_table, _LoadReason, Props}, {Pid,_},
#st{alias = Alias, tab = Tab} = St) -> #st{alias = Alias, tab = Tab} = St) ->
{ok, _Ref} = mnesia_rocksdb_admin:load_table(Alias, Tab, Props), {ok, _Ref} = mnesia_rocksdb_admin:load_table(Alias, Tab, Props),
{reply, ok, St#st{status = active, loaders = [Pid|St#st.loaders]}}; {reply, ok, St#st{status = active}};
handle_call({write_info, Key, Value}, _From, #st{tab = Tab} = St) -> handle_call({write_info, Key, Value}, _From, #st{tab = Tab} = St) ->
mrdb:write_info(get_ref(Tab), Key, Value), mrdb:write_info(get_ref(Tab), Key, Value),
{reply, ok, St}; {reply, ok, St};
@ -824,14 +828,9 @@ handle_call({delete, Key}, _From, St) ->
handle_call({match_delete, Pat}, _From, #st{tab = Tab} = St) -> handle_call({match_delete, Pat}, _From, #st{tab = Tab} = St) ->
Res = mrdb:match_delete(get_ref(Tab), Pat), Res = mrdb:match_delete(get_ref(Tab), Pat),
{reply, Res, St}; {reply, Res, St};
handle_call(close_table, {Pid,_}, #st{alias = Alias, tab = Tab, loaders = Ls} = St) -> handle_call(close_table, {Pid,_}, #st{alias = Alias, tab = Tab} = St) ->
case Ls -- [Pid] of _ = mnesia_rocksdb_admin:close_table(Alias, Tab),
[] -> {reply, ok, St#st{status = undefined}};
_ = mnesia_rocksdb_admin:close_table(Alias, Tab),
{reply, ok, St#st{status = undefined, loaders = []}};
Ls1 ->
{reply, ok, St#st{loaders = Ls1}}
end;
handle_call(delete_table, _From, #st{alias = Alias, tab = Tab} = St) -> handle_call(delete_table, _From, #st{alias = Alias, tab = Tab} = St) ->
ok = mnesia_rocksdb_admin:delete_table(Alias, Tab), ok = mnesia_rocksdb_admin:delete_table(Alias, Tab),
{stop, normal, ok, St#st{status = undefined}}. {stop, normal, ok, St#st{status = undefined}}.