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

Nhse d30 kv1869 #2

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions priv/riak_kv.schema
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,19 @@
{commented, 2}
]}.

%% @doc Deferred reap on failure
%% Should one or more primaries be unavilable the reap following delete will
martinsumner marked this conversation as resolved.
Show resolved Hide resolved
%% not be triggered. Rather than being ignored, it can be deferred by enabling
%% defer_reap_on_failure. This will queue the reap on the reaper untill all
%% primaries are available. The reaper queue will be erased on restart, so
%% further failure may lead to the loss of deferred reaps
{mapping, "defer_reap_on_failure", "riak_kv.defer_reap_on_failure", [
{datatype, flag},
{default, on},

Choose a reason for hiding this comment

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

Not familiar with defaults for flags, but I assume that if you write on here, the Erlang value correspondign to that is true.

Because line 644 of riak_kv_get_fsm states:

app_helper:get_env(riak_kv, defer_reap_on_failure, true)

Choose a reason for hiding this comment

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

Some others have:

{mapping, "buckets.default.allow_mult", "riak_core.default_bucket_props.allow_mult", [
  {datatype, {enum, [true, false]}},
  {default, false},
  hidden
]}.

Copy link
Author

Choose a reason for hiding this comment

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

There is not complete consistency here, but the most common is the on/off flag I think at present

hidden
]}.


%% @doc Whether to allow node to participate in coverage queries.
%% This is used as a manual switch to stop nodes in incomplete states
%% (E.g. doing a full partition repair, or node replace) from participating
Expand Down
4 changes: 2 additions & 2 deletions src/riak_kv_get_core.erl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
{delete_repair,
[{non_neg_integer(), repair_reason()}],
riak_object:riak_object()} |
delete.
{delete, riak_object:riak_object()}.
-type idxresult() :: {non_neg_integer(), result()}.
-type idx_type() :: [{non_neg_integer, 'primary' | 'fallback'}].

Expand Down Expand Up @@ -379,7 +379,7 @@ final_action(GetCore = #getcore{n = N, merged = Merged0, results = Results,
Action =
case ReadRepairs of
[] when ObjState == tombstone, AllResults ->
delete;
{delete, MObj};
[] ->
nop;
_ when ObjState == tombstone, AllResults ->
Expand Down
30 changes: 25 additions & 5 deletions src/riak_kv_get_fsm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -598,13 +598,13 @@ finalize(StateData=#state{get_core = GetCore, trace = Trace}) ->
UpdStateData = StateData#state{get_core = UpdGetCore},

case Action of
delete ->
maybe_delete(UpdStateData);
{delete, TombObj} ->
maybe_delete(UpdStateData, TombObj);
{read_repair, Indices, RepairObj} ->
maybe_read_repair(Indices, RepairObj, UpdStateData);
{delete_repair, Indices, RepairObj} ->
maybe_read_repair(Indices, RepairObj, UpdStateData),
maybe_delete(UpdStateData);
maybe_delete(UpdStateData, RepairObj);
_Nop ->
?DTRACE(Trace, ?C_GET_FSM_FINALIZE, [], ["finalize"]),
ok
Expand All @@ -615,8 +615,10 @@ finalize(StateData=#state{get_core = GetCore, trace = Trace}) ->
%% Maybe issue deletes if all primary nodes are available.
%% Get core will only requestion deletion if all vnodes
%% replies with the same value.
maybe_delete(StateData=#state{n = N, preflist2=Sent, trace=Trace,
req_id=ReqId, bkey=BKey}) ->
maybe_delete(
StateData=#state{
n = N, preflist2=Sent, trace=Trace, req_id=ReqId, bkey=BKey},
TombObj) ->
%% Check sent to a perfect preflist and we can delete
IdealNodes = [{I, Node} || {{I, Node}, primary} <- Sent],
NotCustomN = not using_custom_n_val(StateData),
Expand All @@ -628,9 +630,27 @@ maybe_delete(StateData=#state{n = N, preflist2=Sent, trace=Trace,
_ ->
?DTRACE(Trace, ?C_GET_FSM_MAYBE_DELETE, [0],
["maybe_delete", "nop"]),
maybe_defer_reap(BKey, TombObj),
martinsumner marked this conversation as resolved.
Show resolved Hide resolved
nop
end.

-spec maybe_defer_reap(
{riak_object:bucket(), riak_object:key()}, riak_object:object()) -> ok.
maybe_defer_reap(BKey, TombstoneObj) ->
case app_helper:get_env(riak_kv, delete_mode, 3000) of
keep ->
ok;
_ ->
case app_helper:get_env(riak_kv, defer_reap_on_failure, true) of
true ->
VC = riak_object:vclock(TombstoneObj),
riak_kv_reaper:request_reap(
{BKey, riak_object:delete_hash(VC)});
_ ->
ok
end
end.

using_custom_n_val(#state{n=N, bucket_props=BucketProps}) ->
case lists:keyfind(n_val, 1, BucketProps) of
{_, N} ->
Expand Down