hanoidb
hanoidb copied to clipboard
hanoidb hangs, with unhandled messages in main_loop function in hanoidb_level.erl
I'm getting from time to time some unhandled messages in the main_loop function in hanoidb_level.erl
The messages are unhandled because guards fail to match on the certain State. For example:
{'$call',{<0.706.0>,#Ref<0.0.1.4643>},{begin_incremental_merge,1024}} %% with Ref in State#state.step_merge_ref
{'$reply',#Ref<0.0.3.18586>,step_ok} %% with Ref in State#state.step_merge_ref and in State#state.step_next_ref
{'$call',{<0.715.0>,#Ref<0.0.2.1442>},{begin_incremental_merge,1024}} %% with Ref in State#state.step_next_ref
{'$call',{<0.725.0>,#Ref<0.0.2.1441>},{step_level,0,1024}} %% with Ref in State#state.step_merge_ref
{'$call',{<0.713.0>,#Ref<0.0.8.53125>},{inject,"database/X-10.data"}} %% with State#state.c =/= undefined
Often after such message the app hangs on hanoidb:get()
Example of code which hangs with this https://github.com/brigadier/exampledb/blob/master/db.zip?raw=true database 100% of time:
Db0 = "ip2/db".
application:start(syntax_tools).
application:start(plain_fsm).
application:start(hanoidb).
{ok, Db0H} = hanoidb:open(Db0).
L = lists:seq(1, 1000).
F = fun(I) -> hanoidb:get(Db0H, integer_to_binary(I)), hanoidb:put(Db0H, integer_to_binary(I), <<"123">>) end.
F2 = fun() -> lists:foreach(F, L), erlang:display(ok) end.
F2().
F2().
F2(). %%hangs there
F2(). %%or there
F2(). %%or there
F2(). %%or there
There's no such problem in a very old version of hanoidb, with the old file format etc.