{error, einval} in hanoidb_nursery:transact/3 #12

Closed
norton opened this Issue Sep 24, 2012 · 1 comment

Comments

Projects
None yet
2 participants
Contributor

norton commented Sep 24, 2012

Testing hanoidb's transact API.

I'm able to regularly trigger the following crash in the hanoidb_nursery:transact/3 function.

exception exit: {{{{badmatch,{error,einval}},[{hanoidb_nursery,transact,3,[{file,"src/hanoidb_nursery.erl"},{line,279}]},{hanoidb,do_transact,2,[{file,"src/hanoidb.erl"},{line,434}]},{hanoidb,handle_call,3,[{file,"src/hanoidb.erl"},{line,387}]},{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,588}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,227}]}]},{gen_server,call,[<0.108.0>,{transact,[{put, ....

The crash occurs on the following line:

ok = file:write(File, Data),

Based on code review, the below diff seems like a possible fix:

diff --git a/src/hanoidb_nursery.erl b/src/hanoidb_nursery.erl
index db80f9a..8594223 100644
--- a/src/hanoidb_nursery.erl
+++ b/src/hanoidb_nursery.erl
@@ -264,9 +264,10 @@ ensure_space(Nursery, NeededRoom, Top) ->
             flush(Nursery, Top)
     end.

-transact(Spec, Nursery=#nursery{ log_file=File, cache=Cache0, total_size=TotalS
-    Nursery1 = ensure_space(Nursery, length(Spec), Top),
+transact(Spec, Nursery, Top) ->
+    transact1(Spec, ensure_space(Nursery, length(Spec), Top), Top).

+transact1(Spec, Nursery1=#nursery{ log_file=File, cache=Cache0, total_size=Tota
     Expiry =
         case hanoidb:get_opt(expiry_secs, Config) of
             0 ->

Can you review this diff and also check for similar issues?

Tomorrow, I'll continue further testing.

Owner

krestenkrab commented Sep 24, 2012

Good catch. I fixed this with bac52b0.

jaynel pushed a commit to jaynel/hanoidb that referenced this issue Mar 10, 2014

Fix invalid error
This fixes krestenkrab#12
where an old file descriptor is used when storing
2i (transact data) causes the tx log to roll.

jaynel pushed a commit to jaynel/hanoidb that referenced this issue Mar 10, 2014

Fix case clause error.
This is a fix for commit dce62a8 originally targeted for
krestenkrab#12 where an old file
descriptor is used when storing 2i (transact data) causes the tx log
to roll.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment