Skip to content

Commit

Permalink
Make AAE key estimation API handle illegal IndexN
Browse files Browse the repository at this point in the history
This commit changes riak_kv_index_hashtree to return not_responsible
when provided an illegal IndexN in estimate_keys/2. Prior to this
commit, an invalid IndexN would cause the hashtree process to crash.

Authored-by: Kresten Krab Thorup <krab@trifork.com>
Rebased-by:  Joseph Blomstedt <joe@basho.com>
  • Loading branch information
krestenkrab authored and jtuple committed Oct 7, 2014
1 parent fd443c2 commit 5b47019
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/riak_kv_index_hashtree.erl
Expand Up @@ -336,10 +336,13 @@ handle_call(estimate_keys, _From, State=#state{trees=Trees}) ->
{reply, {ok, EstimateNrKeys}, State};

handle_call({estimate_keys, IndexN}, _From, State=#state{trees=Trees}) ->
{ok, Tree} = orddict:find(IndexN, Trees),
lager:info("emiklix ~p ~p ~p", [IndexN, Trees, Tree]),
{ok, EstimateNrKeys} = hashtree:estimate_keys(Tree),
{reply, {ok, EstimateNrKeys}, State};
case orddict:find(IndexN, Trees) of
{ok, Tree} ->
{ok, EstimateNrKeys} = hashtree:estimate_keys(Tree),
{reply, {ok, EstimateNrKeys}, State};
error ->
{reply, not_responsible, State}
end;

handle_call(_Request, _From, State) ->
Reply = ok,
Expand Down

5 comments on commit 5b47019

@borshop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from engelsanchez
at 5b47019

@borshop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging basho/riak_kv/feature/aae-estimate-keys = 5b47019 into borshop-integration-1030-feature/aae-estimate-keys

@borshop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basho/riak_kv/feature/aae-estimate-keys = 5b47019 merged ok, testing candidate = b432247

@borshop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@borshop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding 2.0 to borshop-integration-1030-feature/aae-estimate-keys = b432247

Please sign in to comment.