Skip to content

Commit 051f834

Browse files
committed
Add aae_range_repairkeys
To propose read repair on a range
1 parent 07c9582 commit 051f834

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

rebar.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
]}.
1818

1919
{deps, [
20-
{riak_pb, {git, "https://github.com/basho/riak_pb", {tag, "3.0.7"}}}
20+
{riak_pb, {git, "https://github.com/basho/riak_pb", {branch, "mas-i1793-repairkeysrange"}}}
2121
]}.
2222

2323
{edoc_opts, [

src/riakc_pb_socket.erl

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@
7373
get_index_eq/4, get_index_range/5, get_index_eq/5, get_index_range/6,
7474
aae_merge_root/2, aae_merge_branches/3,
7575
aae_fetch_clocks/3, aae_fetch_clocks/4,
76-
aae_range_tree/7, aae_range_clocks/5, aae_range_replkeys/5,
76+
aae_range_tree/7, aae_range_clocks/5,
77+
aae_range_replkeys/5, aae_range_repairkeys/4,
7778
aae_find_keys/5, aae_find_tombs/5, aae_reap_tombs/6, aae_erase_keys/6,
7879
aae_list_buckets/1, aae_list_buckets/2,
7980
aae_object_stats/4,
@@ -1631,6 +1632,47 @@ aae_range_replkeys(Pid, BucketType, KeyRange, ModifiedRange, QueueName) ->
16311632
queuename = QN},
16321633
Timeout}).
16331634

1635+
%% @doc aae_range_repairkeys
1636+
%% Fold over a range of keys and in batches prompt read repair of each key
1637+
%% by fetching the key
1638+
-spec aae_range_repairkeys(pid(), riakc_obj:bucket(),
1639+
key_range(), modified_range()) ->
1640+
{ok, non_neg_integer()} |
1641+
{error, any()}.
1642+
aae_range_repairkeys(Pid, BucketType, KeyRange, ModifiedRange) ->
1643+
Timeout = default_timeout(aaefold_timeout),
1644+
{KR, SK, EK} =
1645+
case KeyRange of
1646+
all ->
1647+
{false, undefined, undefined};
1648+
{SK0, EK0} ->
1649+
{true, SK0, EK0}
1650+
end,
1651+
{MR, MRLow, MRHigh} =
1652+
case ModifiedRange of
1653+
all ->
1654+
{false, undefined, undefined};
1655+
{MRL, MRH} ->
1656+
{true, MRL, MRH}
1657+
end,
1658+
{T, B} =
1659+
case BucketType of
1660+
B0 when is_binary(B0) ->
1661+
{undefined, B0};
1662+
{T0, B0} ->
1663+
{T0, B0}
1664+
end,
1665+
call_infinity(Pid,
1666+
{req,
1667+
#rpbaaefoldrepairkeysreq{type = T,
1668+
bucket = B,
1669+
key_range = KR,
1670+
start_key = SK,
1671+
end_key = EK,
1672+
modified_range = MR,
1673+
last_mod_start = MRLow,
1674+
last_mod_end = MRHigh},
1675+
Timeout}).
16341676

16351677
%% @doc aae_find_keys folds over the tictacaae store to get
16361678
%% operational information. `Rhc' is the client. `Bucket' is the
@@ -2730,6 +2772,11 @@ process_response(#request{msg = #rpbaaefoldreplkeysreq{}},
27302772
State) ->
27312773
true = <<"dispatched_count">> == DispatchCount#rpbkeyscount.tag,
27322774
{reply, {ok, DispatchCount#rpbkeyscount.count}, State};
2775+
process_response(#request{msg = #rpbaaefoldrepairkeysreq{}},
2776+
#rpbaaefoldkeycountresp{keys_count = [DispatchCount]},
2777+
State) ->
2778+
true = <<"dispatched_count">> == DispatchCount#rpbkeyscount.tag,
2779+
{reply, {ok, DispatchCount#rpbkeyscount.count}, State};
27332780
process_response(#request{msg = #rpbaaefoldobjectstatsreq{}},
27342781
#rpbaaefoldkeycountresp{keys_count = KeysCount},
27352782
State) ->

0 commit comments

Comments
 (0)