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

Use 'RR' when a prunable vclock is replicated #1866

Merged
merged 3 commits into from
Jul 18, 2023
Merged
Changes from all 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
33 changes: 27 additions & 6 deletions src/riak_kv_put_fsm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -396,21 +396,39 @@ validate(timeout, StateData0 = #state{from = {raw, ReqId, _Pid},
{[{returnbody,true}], false}
end
end,
RObj = apply_updates(RObj0, Options),
RR =
case get_option(asis, Options) of
true ->
Clock = riak_object:vclock(RObj),
MaybePrunedClock =
vclock:prune(
Clock, riak_core_util:moment(), BucketProps),
case {length(MaybePrunedClock), length(Clock)} of
{PVL, UPVL} when PVL < UPVL ->
true;
_ ->
false
end;
_ ->
false
end,
PutCore = riak_kv_put_core:init(N, W, PW, NodeConfirms, DW,
AllowMult,
ReturnBody,
IdxType),
Options1 = lists:keydelete(sync_on_write, 1, Options),
Options2 = [{sync_on_write, SyncOnWrite}|Options1],
VNodeOpts = handle_options(Options2, VNodeOpts0),
Options3 = [{rr, RR}|Options2],
VNodeOpts = handle_options(Options3, VNodeOpts0),
StateData = StateData0#state{n=N,
w=W,
pw=PW, node_confirms=NodeConfirms, dw=DW,
allowmult=AllowMult,
precommit = Precommit,
postcommit = Postcommit,
req_id = ReqId,
robj = apply_updates(RObj0, Options),
robj = RObj,
putcore = PutCore,
vnode_options = VNodeOpts,
timeout = Timeout},
Expand Down Expand Up @@ -777,6 +795,8 @@ handle_options([{K, _V} = Opt|T], Acc)
when K == sloppy_quorum; K == n_val ->
%% Take these options as-is
handle_options(T, [Opt|Acc]);
handle_options([{rr, true}|T], Acc) ->
handle_options(T, [{rr, true}|Acc]);
handle_options([{_,_}|T], Acc) -> handle_options(T, Acc).

%% Invokes the hook and returns a tuple of
Expand Down Expand Up @@ -970,14 +990,15 @@ late_put_fsm_coordinator_ack(_Node) ->

-spec get_bucket_props(riak_object:bucket()) -> list().
get_bucket_props(Bucket) ->
{ok, DefaultProps} = application:get_env(riak_core,
default_bucket_props),
{ok, DefaultProps} = application:get_env(riak_core, default_bucket_props),
BucketProps = riak_core_bucket:get_bucket(Bucket),
%% typed buckets never fall back to defaults
case is_tuple(Bucket) of
false ->
lists:keymerge(1, lists:keysort(1, BucketProps),
lists:keysort(1, DefaultProps));
lists:keymerge(
1,
lists:keysort(1, BucketProps),
lists:keysort(1, DefaultProps));
true ->
BucketProps
end.
Expand Down
Loading