Skip to content

Instantly share code, notes, and snippets.

@kellymclaughlin
Last active August 29, 2015 14:05
Show Gist options
  • Save kellymclaughlin/de3979f77192e1981581 to your computer and use it in GitHub Desktop.
Save kellymclaughlin/de3979f77192e1981581 to your computer and use it in GitHub Desktop.
Effects on Riak key listings when reducing n_val from 3 to 2
(riak@127.0.0.1)3> [C:put(riak_object:new(<<"bucket">>, list_to_binary(integer_to_list(X)), <<"val">>)) || X <- lists:seq(1,100)].
(riak@127.0.0.1)5> Props = riak_core_bucket:get_bucket(<<"bucket">>).
[{name,<<"bucket">>},
 {allow_mult,true},
 {basic_quorum,false},
 {big_vclock,50},
 {chash_keyfun,{riak_core_util,chash_std_keyfun}},
 {dw,quorum},
 {last_write_wins,false},
 {linkfun,{modfun,riak_kv_wm_link_walker,mapreduce_linkfun}},
 {n_val,3},
 {notfound_ok,true},
 {old_vclock,86400},
 {postcommit,[]},
 {pr,0},
 {precommit,[]},
 {pw,0},
 {r,quorum},
 {rw,quorum},
 {small_vclock,50},
 {w,quorum},
 {young_vclock,20}]
(riak@127.0.0.1)6> UpdProps = [{n_val,2} | proplists:delete(n_val, Props)].
[{n_val,2},
 {name,<<"bucket">>},
 {allow_mult,true},
 {basic_quorum,false},
 {big_vclock,50},
 {chash_keyfun,{riak_core_util,chash_std_keyfun}},
 {dw,quorum},
 {last_write_wins,false},
 {linkfun,{modfun,riak_kv_wm_link_walker,mapreduce_linkfun}},
 {notfound_ok,true},
 {old_vclock,86400},
 {postcommit,[]},
 {pr,0},
 {precommit,[]},
 {pw,0},
 {r,quorum},
 {rw,quorum},
 {small_vclock,50},
 {w,quorum},
 {young_vclock,20}]

(riak@127.0.0.1)13> {ok, NVal3Keys} = C:list_keys(<<"bucket">>).            
{ok,[<<"54">>,<<"30">>,<<"28">>,<<"21">>,<<"63">>,<<"3">>,
     <<"29">>,<<"2">>,<<"82">>,<<"24">>,<<"95">>,<<"93">>,
     <<"9">>,<<"86">>,<<"52">>,<<"50">>,<<"47">>,<<"32">>,
     <<"100">>,<<"96">>,<<"78">>,<<"75">>,<<"59">>,<<"99">>,
     <<"49">>,<<"46">>,<<...>>|...]}
(riak@127.0.0.1)14> length(NVal3Keys).
100
(riak@127.0.0.1)15> length(lists:usort(NVal3Keys)).
100
(riak@127.0.0.1)16> riak_core_bucket:set_bucket(<<"bucket">>, UpdProps).    
ok
(riak@127.0.0.1)17> {ok, NVal2Keys} =C:list_kkes(<""bbukket>>>).        
{ok,[<<"58">>,<<"28">>,<<"95">>,<<"93">>,<<"9">>,<<"86">>,
     <<"52">>,<<"50">>,<<"47">>,<<"32">>,<<"100">>,<<"90">>,
     <<"60">>,<<"89">>,<<"63">>,<<"3">>,<<"2">>,<<"88">>,
     <<"79">>,<<"77">>,<<"65">>,<<"38">>,<<"23">>,<<"20">>,
     <<"15">>,<<"94">>,<<...>>|...]}
(riak@127.0.0.1)18> length(NVal2Keys).
154
(riak@127.0.0.1)19> length(lists:usort(NVal2Keys)).
100

This output compares the coverage plan calculated for the same bucket. The first shows with n_val=3 and the second with n_val=2.

Coverage plan with n_val=3:

2014-08-15 15:20:07.900 [info] <0.2972.0>@riak_core_coverage_fsm:initialize:223 CoveragePlan: {[{0,'riak@127.0.0.1'},
{68507889249886074290797726533575766546371837952,'riak@127.0.0.1'},{137015778499772148581595453067151533092743675904,'riak@127.0.0.1'},
{205523667749658222872393179600727299639115513856,'riak@127.0.0.1'},{274031556999544297163190906134303066185487351808,'riak@127.0.0.1'},
{342539446249430371453988632667878832731859189760,'riak@127.0.0.1'},{411047335499316445744786359201454599278231027712,'riak@127.0.0.1'},
{479555224749202520035584085735030365824602865664,'riak@127.0.0.1'},{548063113999088594326381812268606132370974703616,'riak@127.0.0.1'},
{616571003248974668617179538802181898917346541568,'riak@127.0.0.1'},{685078892498860742907977265335757665463718379520,'riak@127.0.0.1'},
{753586781748746817198774991869333432010090217472,'riak@127.0.0.1'},{822094670998632891489572718402909198556462055424,'riak@127.0.0.1'},
{890602560248518965780370444936484965102833893376,'riak@127.0.0.1'},{959110449498405040071168171470060731649205731328,'riak@127.0.0.1'},
{1027618338748291114361965898003636498195577569280,'riak@127.0.0.1'},{1096126227998177188652763624537212264741949407232,'riak@127.0.0.1'},
{1164634117248063262943561351070788031288321245184,'riak@127.0.0.1'},{1233142006497949337234359077604363797834693083136,'riak@127.0.0.1'},
{1301649895747835411525156804137939564381064921088,'riak@127.0.0.1'},{1370157784997721485815954530671515330927436759040,'riak@127.0.0.1'},
{1392993748081016843912887106182707253109560705024,'riak@127.0.0.1'}],[{1392993748081016843912887106182707253109560705024,
[1392993748081016843912887106182707253109560705024]}]}

Coverage plan with n_val=2:

2014-08-15 15:23:40.029 [info] <0.4583.0>@riak_core_coverage_fsm:initialize:223 CoveragePlan: {[{0,'riak@127.0.0.1'},
{45671926166590716193865151022383844364247891968,'riak@127.0.0.1'},{91343852333181432387730302044767688728495783936,'riak@127.0.0.1'},
{137015778499772148581595453067151533092743675904,'riak@127.0.0.1'},{182687704666362864775460604089535377456991567872,'riak@127.0.0.1'},
{228359630832953580969325755111919221821239459840,'riak@127.0.0.1'},{274031556999544297163190906134303066185487351808,'riak@127.0.0.1'},
{319703483166135013357056057156686910549735243776,'riak@127.0.0.1'},{365375409332725729550921208179070754913983135744,'riak@127.0.0.1'},
{411047335499316445744786359201454599278231027712,'riak@127.0.0.1'},{456719261665907161938651510223838443642478919680,'riak@127.0.0.1'},
{502391187832497878132516661246222288006726811648,'riak@127.0.0.1'},{548063113999088594326381812268606132370974703616,'riak@127.0.0.1'},
{593735040165679310520246963290989976735222595584,'riak@127.0.0.1'},{639406966332270026714112114313373821099470487552,'riak@127.0.0.1'},
{685078892498860742907977265335757665463718379520,'riak@127.0.0.1'},{730750818665451459101842416358141509827966271488,'riak@127.0.0.1'},
{776422744832042175295707567380525354192214163456,'riak@127.0.0.1'},{822094670998632891489572718402909198556462055424,'riak@127.0.0.1'},
{867766597165223607683437869425293042920709947392,'riak@127.0.0.1'},{913438523331814323877303020447676887284957839360,'riak@127.0.0.1'},
{959110449498405040071168171470060731649205731328,'riak@127.0.0.1'},{1004782375664995756265033322492444576013453623296,'riak@127.0.0.1'},
{1050454301831586472458898473514828420377701515264,'riak@127.0.0.1'},{1096126227998177188652763624537212264741949407232,'riak@127.0.0.1'},
{1141798154164767904846628775559596109106197299200,'riak@127.0.0.1'},{1187470080331358621040493926581979953470445191168,'riak@127.0.0.1'},
{1233142006497949337234359077604363797834693083136,'riak@127.0.0.1'},{1278813932664540053428224228626747642198940975104,'riak@127.0.0.1'},
{1324485858831130769622089379649131486563188867072,'riak@127.0.0.1'},{1370157784997721485815954530671515330927436759040,'riak@127.0.0.1'},
{1415829711164312202009819681693899175291684651008,'riak@127.0.0.1'}],[]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment