From ab6b974830cfaaf9cbd55dc93d2c7d4960083ad3 Mon Sep 17 00:00:00 2001 From: Kresten Krab Thorup Date: Mon, 7 May 2012 01:48:48 +0200 Subject: [PATCH] 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. --- src/hanoi.erl | 6 +++++- src/riak_kv_hanoi_backend.erl | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/hanoi.erl b/src/hanoi.erl index 57460c5..e3c1b35 100644 --- a/src/hanoi.erl +++ b/src/hanoi.erl @@ -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. diff --git a/src/riak_kv_hanoi_backend.erl b/src/riak_kv_hanoi_backend.erl index 785a175..d7c3e73 100644 --- a/src/riak_kv_hanoi_backend.erl +++ b/src/riak_kv_hanoi_backend.erl @@ -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(<<>>, '_'); _ ->