Skip to content

Commit

Permalink
Develop d30updated (#1841)
Browse files Browse the repository at this point in the history
* Do not crash when object's contents is an empty list (#1837)

* Add test to illustrate issue

* Do not crash when object's contents is an empty list

* add missing function clause repair_keys_range in convert_fold (#1839)

* add missing function clause repair_keys_range in convert_fold, to unbreak aae_fold for that case

* thread converted aae_fold query in riak_client, to complete prev commit

* Change the default PR value from 0 to default (#1836)

This means that get requests will use bucket-type level Primary Read settings

Co-authored-by: Peter Tihanyi <peter.tihanyi@otpbank.hu>

* Mas i1121 reip3 (#1838)

* Add reip/3

To allow for reip without loading the riak_core application

* Use alternate name

* Update riak_kv_console.erl

* Update riak_kv_console.erl

* reip_manual inputs are atoms

* Add warning to update riak.conf file after reip

* Make clear where attention is required

And return 'ok' to make clear the op was successful

* Update rebar.config

* Update log (#1840)

Make situation clearer in log

Rather than change behaviour, just make it clear that the warning can be ignored when shutting down.  This should avoid unnecessary concern.

* Update Readme, remove mercurial refs

Co-authored-by: Enrique Fernández <efcasado@gmail.com>
Co-authored-by: Andrei Zavada <johnhommer@gmail.com>
Co-authored-by: Peter Tihanyi <tihi@systream.hu>
Co-authored-by: Peter Tihanyi <peter.tihanyi@otpbank.hu>
  • Loading branch information
5 people committed Dec 19, 2022
1 parent 5fc3808 commit d6357d8
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 22 deletions.
5 changes: 0 additions & 5 deletions .hgignore

This file was deleted.

9 changes: 0 additions & 9 deletions .hgtags

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
* riak_kv
** Overview

[![Erlang CI Actions Status](https://github.com/basho/riak_kv/workflows/Erlang%20CI/badge.svg)](https://github.com/basho/riak_kv/actions)
[[https://github.com/basho/riak_kv/actions][Build Status]] - [[https://github.com/basho/riak_kv/actions/workflows/erlang.yml/badge.svg?branch=develop]]

Riak KV is an open source Erlang application that is distributed using the [[https://github.com/basho/riak_core][riak_core]] Erlang
Riak KV is an open source Erlang application that is distributed using the [[https://github.com/basho/riak_core][riak_core]] Erlang
library. Riak KV provides a key/value datastore and features MapReduce, lightweight data relations, and several different client APIs.

** Quick Start
You must have [[http://erlang.org/download.html][Erlang/OTP 20 or 22]] or later and a GNU-style build
You must have [[http://erlang.org/download.html][Erlang/OTP 22, 24 or 25]] or later and a GNU-style build
system to compile and run =riak_kv=. The easiest way to utilize riak_kv is by installing the full
Riak application available on [[https://github.com/basho/riak][Github]].

Expand Down
2 changes: 1 addition & 1 deletion src/riak_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ aae_fold(Query, {?MODULE, [Node, _ClientId]}) ->
true ->
riak_kv_clusteraae_fsm_sup:start_clusteraae_fsm(Node,
[{raw, ReqId, Me},
[Query, TimeOut]]),
[Q0, TimeOut]]),
wait_for_fold_results(ReqId, TimeOut);
false ->
{error, "Invalid AAE fold definition"}
Expand Down
2 changes: 2 additions & 0 deletions src/riak_kv_clusteraae_fsm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,8 @@ convert_fold({find_tombs, B, KR, SF, MR}) ->
{find_tombs, B, KR, SF, convert_modrange(MR)};
convert_fold({reap_tombs, B, KR, SF, MR, CM}) ->
{reap_tombs, B, KR, SF, convert_modrange(MR), CM};
convert_fold({repair_keys_range, B, KR, MR, L}) ->
{repair_keys_range, B, KR, convert_modrange(MR), L};
convert_fold({erase_keys, B, KR, SF, MR, CM}) ->
{erase_keys, B, KR, SF, convert_modrange(MR), CM};
convert_fold(Fold) ->
Expand Down
35 changes: 35 additions & 0 deletions src/riak_kv_console.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
status/1,
vnode_status/1,
reip/1,
reip_manual/1,
ringready/1,
cluster_info/1,
down/1,
Expand Down Expand Up @@ -234,6 +235,40 @@ reip([OldNode, NewNode]) ->
error
end.

reip_manual([OldNode, NewNode, Dir, ClusterName]) ->
try
%% reip/1 requires riak_core to be loaded to learn the Ring Directory
%% and the Cluster Name. In reip_manual/1 these can be passed in
%% instead
RingDir = atom_to_list(Dir),
Cluster = atom_to_list(ClusterName),
{ok, RingFile} =
riak_core_ring_manager:find_latest_ringfile(RingDir, Cluster),
io:format("~nCHANGE DETAILS:~n"),
io:format("RingFile to update ~p~n", [RingFile]),
BackupFN =
filename:join([RingDir, filename:basename(RingFile)++".BAK"]),
{ok, _} = file:copy(RingFile, BackupFN),
io:format("Backed up existing ring file to ~p~n", [BackupFN]),
Ring = riak_core_ring_manager:read_ringfile(RingFile),
NewRing = riak_core_ring:rename_node(Ring, OldNode, NewNode),
NewRingFN =
riak_core_ring_manager:generate_ring_filename(
RingDir, Cluster),
ok = riak_core_ring_manager:do_write_ringfile(NewRing, NewRingFN),
io:format("New ring file written to ~p~n", [NewRingFN]),
io:format("~nATTENTION REQUIRED:~n"),
io:format(
"Update required to riak.conf nodename before restarting node;"
++ " nodename should be changed to ~s~n",
[atom_to_list(NewNode)]),
io:format("~nok~n")
catch
Exception:Reason ->
io:format("Reip failed ~p:~p", [Exception, Reason]),
error
end.

%% Check if all nodes in the cluster agree on the partition assignment
-spec(ringready([]) -> ok | error).
ringready([]) ->
Expand Down
3 changes: 1 addition & 2 deletions src/riak_kv_get_fsm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@

-define(DEFAULT_TIMEOUT, 60000).
-define(DEFAULT_R, default).
-define(DEFAULT_PR, 0).
-define(DEFAULT_PR, default).
-define(DEFAULT_RT, head).
-define(DEFAULT_NC, 0).
-define(QUEUE_EMPTY_LOOPS, 8).

%% ===================================================================
Expand Down
6 changes: 4 additions & 2 deletions src/riak_kv_index_hashtree.erl
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,10 @@ fold_fun(HashtreePid, _HasIndexTree = true) ->
-spec handle_corrupted_object(
riak_object:bucket(), riak_object:key(), term(), term()) -> ok.
handle_corrupted_object(Bucket, Key, Error, Reason) ->
?LOG_WARNING("Unable to read B=~p K=~p", [Bucket, Key]),
?LOG_WARNING("Read failure due to ~w ~w", [Error, Reason]),
?LOG_WARNING(
"Unable to read B=~p K=~p due to ~p ~p during tree rebuild " ++
"so will prompt read_repair - ignore warning during shutdown",
[Bucket, Key, Error, Reason]),
riak_kv_reader:request_read({Bucket, Key}).

-spec object_fold_fun(pid()) ->
Expand Down
13 changes: 13 additions & 0 deletions src/riak_object.erl
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ find_bestobject(FetchedItems) ->

-spec is_head({ok, riak_object()}|riak_object()) -> boolean().
%% @private Check if an object is simply a head response
is_head({ok, #r_object{contents=[]}}) ->
false;
is_head({ok, #r_object{contents=Contents}}) ->
C0 = lists:nth(1, Contents),
case C0#r_content.value of
Expand Down Expand Up @@ -1678,6 +1680,17 @@ delete_hash(ObjOrClock) ->

-ifdef(TEST).

%% See https://github.com/basho/riak_kv/issues/1707
object_with_empty_contents_test() ->
B = <<"buckets_are_binaries">>,
K = <<"keys are binaries">>,

Contents = [],
O = #r_object{bucket=B,key=K,
contents=Contents,vclock=vclock:fresh()},

?assertEqual(false, is_head(O)).

object_test() ->
B = <<"buckets_are_binaries">>,
K = <<"keys are binaries">>,
Expand Down

0 comments on commit d6357d8

Please sign in to comment.