Skip to content

Commit

Permalink
Merge pull request #957 from basho/develop-3.0-292
Browse files Browse the repository at this point in the history
Develop 3.0 292
  • Loading branch information
martinsumner authored May 7, 2020
2 parents ce810ce + 06b078d commit 4f1593f
Show file tree
Hide file tree
Showing 23 changed files with 203 additions and 95 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ _build
rebar.lock
.DS_Store
nonode@nohost
data/*
test/*.beam
log/*
core_vnode_eqc.log
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
language: erlang
otp_release:
- 20.3.8
- 21.3
- 22.3
script:
- chmod u+x rebar3
- ./rebar3 do upgrade, compile, dialyzer, xref, eunit
Expand Down
2 changes: 1 addition & 1 deletion eqc/worker_pool_pulse.erl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ handle_work(Work, _From, State) ->

%% @doc Any amount of work should complete through any size pool.
prop_any_pool() ->
?SETUP(fun setup_and_teardown/1,
?SETUP(fun setup_and_teardown/0,
?FORALL({Seed, ExtraWork, WorkList},
{pulse:seed(),
frequency([{10,true},{1,false}]),
Expand Down
32 changes: 18 additions & 14 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
{erl_first_files, ["src/gen_nb_server.erl", "src/riak_core_gen_server.erl",
"src/riak_core_stat_xform"]}.

{cover_enabled, true}.

{erl_opts, [warnings_as_errors,
{parse_transform, lager_transform},
debug_info,
{platform_define, "^[0-9]+", namespaced_types},
{platform_define, "^R15", "old_hash"},
{platform_define, "^[2-9][1-9][0-9]*(.?[0-9]*)", deprecated_21}]}.
{platform_define, "^[2-9][1-9][0-9]*(.?[0-9]*)", deprecated_21},
{platform_define, "^[2-9][2-9][0-9]*(.?[0-9]*)", deprecated_22}]}.

{edoc_opts, [{preprocess, true}]}.

{eunit_opts, [verbose]}.
{xref_checks,[undefined_function_calls,undefined_functions,locals_not_used,
deprecated_function_calls, deprecated_functions]}.

{plugins, [{rebar3_eqc, {git, "https://github.com/Vagabond/rebar3-eqc-plugin", {branch, "master"}}}]}.
{xref_checks,[undefined_function_calls,undefined_functions,locals_not_used]}.

{plugins, [{eqc_rebar, {git, "https://github.com/Quviq/eqc-rebar", {branch, "master"}}}]}.

{deps, [
{lager, ".*", {git, "git://github.com/erlang-lager/lager.git", {tag, "3.6.10"}}},
{poolboy, ".*", {git, "https://github.com/Kyorai/poolboy.git", {branch, "r21"}}},
{basho_stats, ".*", {git, "git://github.com/basho/basho_stats.git", {branch, "develop-3.0"}}},
{riak_sysmon, "~>2.1.7"},
{clique, ".*", {git, "git://github.com/basho/clique.git", {branch, "develop-3.0"}}},
gen_fsm_compat,
{eleveldb, ".*", {git, "git://github.com/basho/eleveldb.git", {branch, "develop-3.0"}}},
{riak_ensemble, ".*", {git, "https://github.com/basho/riak_ensemble", {branch, "develop-3.0"}}},
{pbkdf2, ".*", {git, "git://github.com/basho/erlang-pbkdf2.git", {branch, "develop-3.0"}}},
{lager, {git, "git://github.com/erlang-lager/lager.git", {tag, "3.8.0"}}},
{poolboy, {git, "https://github.com/basho/poolboy.git", {branch, "develop-3.0"}}},
{riak_sysmon, {git, "git://github.com/basho/riak_sysmon.git", {branch, "develop-3.0"}}},
{clique, {git, "git://github.com/basho/clique.git", {branch, "develop-3.0"}}},
{eleveldb, {git, "git://github.com/basho/eleveldb.git", {branch, "develop-3.0"}}},
{riak_ensemble, {git, "https://github.com/basho/riak_ensemble", {branch, "develop-3.0"}}},
{pbkdf2, {git, "git://github.com/basho/erlang-pbkdf2.git", {branch, "develop-3.0"}}},
{cluster_info, {git, "git://github.com/basho/cluster_info.git", {branch, "develop-3.0"}}},
exometer_core
{exometer_core, {git, "git://github.com/Feuerlabs/exometer_core.git", {tag, "v1.5.7"}}},
{basho_stats, {git, "git://github.com/basho/basho_stats.git", {branch, "develop-3.0"}}}
]}.

{dialyzer, [{plt_apps, all_deps}]}.
Expand Down
Binary file modified rebar3
Binary file not shown.
2 changes: 1 addition & 1 deletion src/hashtree.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ compare(Level, Bucket, Tree, Remote, AccFun, KeyAcc) ->
Inter = ordsets:intersection(ordsets:from_list(HL1),
ordsets:from_list(HL2)),
Diff = ordsets:subtract(Union, Inter),
lager:debug("Tree ~p level ~p bucket ~p\nL=~p\nR=~p\nD=\n",
lager:debug("Tree ~p level ~p bucket ~p\nL=~p\nR=~p\nD=~p\n",
[Tree, Level, Bucket, HL1, HL2, Diff]),
KeyAcc3 =
lists:foldl(fun({Bucket2, _}, KeyAcc2) ->
Expand Down
3 changes: 1 addition & 2 deletions src/riak_core.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
crypto,
riak_sysmon,
os_mon,
basho_stats,
eleveldb,
pbkdf2,
poolboy,
exometer_core,
clique,
cluster_info,
gen_fsm_compat
basho_stats
]},
{mod, {riak_core_app, []}},
{env, [
Expand Down
24 changes: 18 additions & 6 deletions src/riak_core_claim.erl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
-compile(export_all).
-ifdef(EQC).
-export([prop_claim_ensures_unique_nodes/1, prop_wants/0, prop_wants_counts/0,eqc_check/2,
prop_claim_ensures_unique_nodes_v2/0, prop_claim_ensures_unique_nodes_v3/0,
prop_claim_ensures_unique_nodes_v2/0, % prop_claim_ensures_unique_nodes_v3/0,
prop_take_idxs/0]).
-include_lib("eqc/include/eqc.hrl").
-endif.
Expand Down Expand Up @@ -1364,15 +1364,27 @@ claim_ensures_unique_nodes_adding_singly_v2_test_() ->
{timeout, 120, fun() -> ?assert(eqc:quickcheck(Prop)) end}.

%% Run few tests in eunit and more if needed by calling "./rebar3 eqc"
claim_ensures_unique_nodes_v3_test_() ->
Prop = eqc:numtests(5, ?QC_OUT(prop_claim_ensures_unique_nodes_old(choose_claim_v3))),
{timeout, 240, fun() -> ?assert(eqc:quickcheck(Prop)) end}.
% claim_ensures_unique_nodes_v3_test_() ->
% Prop = eqc:numtests(5, ?QC_OUT(prop_claim_ensures_unique_nodes_old(choose_claim_v3))),
% {timeout, 240, fun() -> ?assert(eqc:quickcheck(Prop)) end}.

prop_claim_ensures_unique_nodes_v2() ->
prop_claim_ensures_unique_nodes(choose_claim_v2).

prop_claim_ensures_unique_nodes_v3() ->
prop_claim_ensures_unique_nodes(choose_claim_v3).
%% No longer test properties of claim_v3.
%% Although claim_v3 continues to exist as a hidden configuration option, it
%% is known to fail to meet the required properties, and claim_v2 should be
%% used in all known circumstances.
%%
%% TODO : Remove claim_v3 from the code base
%%
%% This TODO is currently deferred due to the difficulty of understanding
%% how to test the full possibility of cluster change scenarios. Perhaps
%% there may be circumstances where a probabilistic approach to planning
%% cluster changes may still be beneficial
%%
% prop_claim_ensures_unique_nodes_v3() ->
% prop_claim_ensures_unique_nodes(choose_claim_v3).

%% NOTE: this is a less than adequate test that has been re-instated
%% so that we don't leave the code worse than we found it. Work that
Expand Down
3 changes: 2 additions & 1 deletion src/riak_core_claim_sim.erl
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,8 @@ run_test() ->
{analysis, [{failures, 2},{n_val, 3}]},
{print,Fh},
{return_ring, false}])),
file:close(Fh).
file:close(Fh),
file:delete("sim.out").


%% Decided not to run by default, perhaps better as an
Expand Down
16 changes: 10 additions & 6 deletions src/riak_core_coverage_fsm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@

-include("riak_core_vnode.hrl").

-behaviour(gen_fsm_compat).
-behaviour(gen_fsm).

-compile({nowarn_deprecated_function,
[{gen_fsm, start_link, 3},
{gen_fsm, start_timer, 2}]}).

-export([start_link/3]).

Expand All @@ -74,7 +78,7 @@
-export([test_link/5]).
-endif.

%% gen_fsm_compat callbacks
%% gen_fsm callbacks
-export([init/1,
initialize/2,
waiting_results/2,
Expand Down Expand Up @@ -142,7 +146,7 @@
-spec start_link(module(), from(), [term()]) ->
{ok, pid()} | ignore | {error, term()}.
start_link(Mod, From, RequestArgs) ->
gen_fsm_compat:start_link(?MODULE, [Mod, From, RequestArgs], []).
gen_fsm:start_link(?MODULE, [Mod, From, RequestArgs], []).

%% ===================================================================
%% Test API
Expand All @@ -153,7 +157,7 @@ start_link(Mod, From, RequestArgs) ->
%% Create a coverage FSM for testing.
test_link(Mod, From, RequestArgs, _Options, StateProps) ->
Timeout = 60000,
gen_fsm_compat:start_link(?MODULE,
gen_fsm:start_link(?MODULE,
{test,
[Mod,
From,
Expand All @@ -165,7 +169,7 @@ test_link(Mod, From, RequestArgs, _Options, StateProps) ->
-endif.

%% ====================================================================
%% gen_fsm_compat callbacks
%% gen_fsm callbacks
%% ====================================================================

%% @private
Expand Down Expand Up @@ -214,7 +218,7 @@ maybe_start_timeout_timer(infinity) ->
maybe_start_timeout_timer(Bad) when not is_integer(Bad) ->
maybe_start_timeout_timer(?DEFAULT_TIMEOUT);
maybe_start_timeout_timer(Timeout) ->
gen_fsm_compat:start_timer(Timeout, {timer_expired, Timeout}),
gen_fsm:start_timer(Timeout, {timer_expired, Timeout}),
ok.


Expand Down
2 changes: 1 addition & 1 deletion src/riak_core_gen_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
%%% Preprocessor
%%%=========================================================================

-ifdef(deprecated_21).
-ifdef(deprecated_22).
get_log(Debug) ->
sys:get_log(Debug).
-else.
Expand Down
6 changes: 5 additions & 1 deletion src/riak_core_handoff_receiver.erl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
-module(riak_core_handoff_receiver).
-include("riak_core_handoff.hrl").
-behaviour(riak_core_gen_server).

-compile({nowarn_deprecated_function,
[{gen_fsm, sync_send_all_state_event, 3}]}).

-export([start_link/0, % Don't use SSL
start_link/1, % SSL options list, empty=no SSL
set_socket/2,
Expand Down Expand Up @@ -141,7 +145,7 @@ process_message(?PT_MSG_BATCH, MsgData, State) ->
process_message(?PT_MSG_OBJ, MsgData, State=#state{vnode=VNode, count=Count,
vnode_timeout_len=VNodeTimeout}) ->
Msg = {handoff_data, MsgData},
try gen_fsm_compat:sync_send_all_state_event(VNode, Msg, VNodeTimeout) of
try gen_fsm:sync_send_all_state_event(VNode, Msg, VNodeTimeout) of
ok ->
State#state{count=Count+1};
E={error, _} ->
Expand Down
14 changes: 9 additions & 5 deletions src/riak_core_handoff_sender.erl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

-module(riak_core_handoff_sender).
-export([start_link/4, get_handoff_ssl_options/0]).

-compile({nowarn_deprecated_function,
[{gen_fsm, send_event, 2}]}).

-include("riak_core_vnode.hrl").
-include("riak_core_handoff.hrl").
-include("stacktrace.hrl").
Expand Down Expand Up @@ -252,9 +256,9 @@ start_fold(TargetNode, Module, {Type, Opts}, ParentPid, SslOpts) ->
riak_core_format:human_size_fmt("~.2f", ThroughputBytes)]),
case Type of
repair -> ok;
resize -> gen_fsm_compat:send_event(ParentPid, {resize_transfer_complete,
resize -> gen_fsm:send_event(ParentPid, {resize_transfer_complete,
NotSentAcc});
_ -> gen_fsm_compat:send_event(ParentPid, handoff_complete)
_ -> gen_fsm:send_event(ParentPid, handoff_complete)
end;
{error, ErrReason} ->
if ErrReason == timeout ->
Expand All @@ -274,15 +278,15 @@ start_fold(TargetNode, Module, {Type, Opts}, ParentPid, SslOpts) ->
exit({shutdown, timeout});
exit:{shutdown, {error, Reason}} ->
?log_fail("because of ~p", [Reason]),
gen_fsm_compat:send_event(ParentPid, {handoff_error,
gen_fsm:send_event(ParentPid, {handoff_error,
fold_error, Reason}),
exit({shutdown, {error, Reason}});
throw:{be_quiet, Err, Reason} ->
gen_fsm_compat:send_event(ParentPid, {handoff_error, Err, Reason});
gen_fsm:send_event(ParentPid, {handoff_error, Err, Reason});
?_exception_(Err, Reason, StackToken) ->
?log_fail("because of ~p:~p ~p",
[Err, Reason, ?_get_stacktrace_(StackToken)]),
gen_fsm_compat:send_event(ParentPid, {handoff_error, Err, Reason})
gen_fsm:send_event(ParentPid, {handoff_error, Err, Reason})
end.

start_visit_item_timer() ->
Expand Down
20 changes: 12 additions & 8 deletions src/riak_core_metadata_exchange_fsm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@
%% -------------------------------------------------------------------
-module(riak_core_metadata_exchange_fsm).

-behaviour(gen_fsm_compat).
-behaviour(gen_fsm).

-compile({nowarn_deprecated_function,
[{gen_fsm, start, 3},
{gen_fsm, send_event, 2}]}).

%% API
-export([start/2]).

%% gen_fsm_compat callbacks
%% gen_fsm callbacks
-export([init/1, handle_event/3, handle_sync_event/4,
handle_info/3, terminate/3, code_change/4]).

%% gen_fsm_compat states
%% gen_fsm states
-export([prepare/2,
prepare/3,
update/2,
Expand Down Expand Up @@ -71,14 +75,14 @@
%% to aqcuire the remote lock or to upate both trees.
-spec start(node(), pos_integer()) -> {ok, pid()} | ignore | {error, term()}.
start(Peer, Timeout) ->
gen_fsm_compat:start(?MODULE, [Peer, Timeout], []).
gen_fsm:start(?MODULE, [Peer, Timeout], []).

%%%===================================================================
%%% gen_fsm_compat callbacks
%%% gen_fsm callbacks
%%%===================================================================

init([Peer, Timeout]) ->
gen_fsm_compat:send_event(self(), start),
gen_fsm:send_event(self(), start),
{ok, prepare, #state{peer=Peer,built=0,timeout=Timeout}}.

handle_event(_Event, StateName, State) ->
Expand All @@ -98,7 +102,7 @@ code_change(_OldVsn, StateName, State, _Extra) ->
{ok, StateName, State}.

%%%===================================================================
%%% gen_fsm_compat states
%%% gen_fsm states
%%%===================================================================
prepare(start, State) ->
%% get local lock
Expand Down Expand Up @@ -296,6 +300,6 @@ as_event(F) ->
Self = self(),
spawn_link(fun() ->
Result = F(),
gen_fsm_compat:send_event(Self, Result)
gen_fsm:send_event(Self, Result)
end),
ok.
12 changes: 9 additions & 3 deletions src/riak_core_ring_manager.erl
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ do_write_ringfile(Ring) ->
do_write_ringfile(Ring, FN) ->
ok = filelib:ensure_dir(FN),
try
false = riak_core_ring:check_lastgasp(Ring),
ok = riak_core_util:replace_file(FN, term_to_binary(Ring))
catch
_:Err ->
Expand Down Expand Up @@ -274,8 +275,11 @@ find_latest_ringfile() ->
read_ringfile(RingFile) ->
case file:read_file(RingFile) of
{ok, Binary} ->
binary_to_term(Binary);
{error, Reason} -> {error, Reason}
R = binary_to_term(Binary),
false = riak_core_ring:check_lastgasp(R),
R;
{error, Reason} ->
{error, Reason}
end.

%% @spec prune_ringfiles() -> ok | {error, Reason}
Expand Down Expand Up @@ -748,7 +752,9 @@ do_write_ringfile_test() ->
%% Check rename fails
ok = file:change_mode(?TEST_RINGDIR, 8#00444),
?assertMatch({error,_}, do_write_ringfile(GenR(ring_perms), ?TEST_RINGFILE)),
ok = file:change_mode(?TEST_RINGDIR, 8#00755).
ok = file:change_mode(?TEST_RINGDIR, 8#00755),
ok = file:change_mode(?TEST_RINGFILE, 8#00644),
ok = file:delete(?TEST_RINGFILE).

is_stable_ring_test() ->
{A,B,C} = Now = os:timestamp(),
Expand Down
Loading

0 comments on commit 4f1593f

Please sign in to comment.