Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operation aborts if any file contains a corrupt key [JIRA: RIAK-2371] #230

Open
joecaswell opened this issue Feb 2, 2016 · 1 comment
Open

Comments

@joecaswell
Copy link

The bitcask backend wraps the key transformation function KT() in a try/catch each time it is called:

K = try KT(K0) catch TxErr -> {key_tx_error, TxErr} end,

However, the TxErr will only match explicitly thrown exceptions. In the case of riak_kv_bitcask_backend:key_transform_to_1/1, if an invalid key is encountered the exception thrown is:

{error,function_clause,[{riak_kv_bitcask_backend,key_transform_to_1,[<<>>],[{file,"src/riak_kv_bitcask_backend.erl"},{line,99}]}

which is not caught by the above pattern.

Proper fix is to rework every instances where a key transform is called to use the Class:Exception pattern so exceptions are actually caught.

As an interim workaround, adding a catch-all clause to the transform functions that explicitly throws an exception would allow the existing catch pattern to match for many cases:

key_transform_to_1(<<?VERSION_1:7, _:1, _Rest/binary>> = Key) ->
    Key;
key_transform_to_1(<<131:8,_Rest/bits>> = Key0) ->
    {Bucket, Key} = binary_to_term(Key0),
    make_bk(?VERSION_BYTE, Bucket, Key);
key_transform_to_1(BadKey) ->
    throw({invalid_key, BadKey}).`
@Basho-JIRA Basho-JIRA changed the title Operation aborts if any file contains a corrupt key Operation aborts if any file contains a corrupt key [JIRA: RIAK-2371] Feb 2, 2016
@evanmcc
Copy link
Contributor

evanmcc commented Feb 3, 2016

I wish that was the first time that particular typo had bitten me, but I suppose that I'll never learn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants