Skip to content

Commit 8370dbf

Browse files
committed
Add failing scan error test
This test demonstrates that when Bitcask's scan files operation fails, a keydir object is created, not marked ready and left behind. Subsequent open operations are unable to succeed because they try to wait for this existing keydir to be ready when its data loads. But this will never happen, so sadness ensues.
1 parent 560716f commit 8370dbf

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/bitcask.erl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3210,6 +3210,26 @@ update_tstamp_stats_test2() ->
32103210
bitcask_time:test__clear_fudge()
32113211
end.
32123212

3213+
scan_err_test_() ->
3214+
{setup,
3215+
fun() ->
3216+
meck:new(bitcask_fileops, [passthrough]),
3217+
ok
3218+
end,
3219+
fun(_) ->
3220+
meck:unload()
3221+
end,
3222+
[fun() ->
3223+
Dir = "/tmp/bc.scan.err",
3224+
meck:expect(bitcask_fileops, data_file_tstamps,
3225+
fun(_) -> {error, because} end),
3226+
?assertMatch({error, _}, bitcask:open(Dir)),
3227+
meck:unload(bitcask_fileops),
3228+
B = bitcask:open(Dir),
3229+
?assertMatch({true, B}, {is_reference(B), B}),
3230+
ok = bitcask:close(B)
3231+
end]}.
3232+
32133233
total_byte_stats_test_() ->
32143234
{timeout, 60, fun total_byte_stats_test2/0}.
32153235

0 commit comments

Comments
 (0)