Fix list_buckets

List buckets was blocking riak, because file-level
range folds sends too many values. This makes
range fold stable towards such cases.
This commit is contained in:
Kresten Krab Thorup 2012-05-07 01:48:48 +02:00
parent 6b6f4417c1
commit ab6b974830
2 changed files with 8 additions and 4 deletions

View file

@ -211,12 +211,14 @@ drain_worker_and_throw(MRef, PID, ExitTuple) ->
?CAST(_,{fold_done, PID}) ->
erlang:demonitor(MRef, [flush]),
raise(ExitTuple)
after 0 ->
raise(ExitTuple)
end.
drain_worker_and_return(MRef, PID, Value) ->
receive
?CALL(_From,{fold_result, PID, _, _}) ->
drain_worker_and_throw(MRef, PID, Value);
drain_worker_and_return(MRef, PID, Value);
{'DOWN', MRef, _, _, _} ->
Value;
?CAST(_,{fold_limit, PID, _}) ->
@ -225,6 +227,8 @@ drain_worker_and_return(MRef, PID, Value) ->
?CAST(_,{fold_done, PID}) ->
erlang:demonitor(MRef, [flush]),
Value
after 0 ->
Value
end.

View file

@ -196,7 +196,7 @@ delete(Bucket, PrimaryKey, IndexSpecs, #state{tree=Tree}=State) ->
fold_buckets(FoldBucketsFun, Acc, Opts, #state{tree=Tree}) ->
BucketFolder =
fun() ->
fold_list_buckets(<<>>, Tree, FoldBucketsFun, Acc)
fold_list_buckets(undefined, Tree, FoldBucketsFun, Acc)
end,
case proplists:get_bool(async_fold, Opts) of
true ->
@ -207,8 +207,8 @@ fold_buckets(FoldBucketsFun, Acc, Opts, #state{tree=Tree}) ->
fold_list_buckets(PrevBucket, Tree, FoldBucketsFun, Acc) ->
case Acc of
?log("fold_list_buckets prev=~p~n", [PrevBucket]),
case PrevBucket of
undefined ->
RangeStart = to_object_key(<<>>, '_');
_ ->