Skip to content

Commit ab865f8

Browse files
committed
Update Khepri from 0.14.0 to 0.15.0
Release notes: https://github.com/rabbitmq/khepri/releases/tag/v0.15.0 The `favor` default value is now `low_latency`. Therefore, we don't need to specify it explicitly anymore.
1 parent 5331b1a commit ab865f8

File tree

3 files changed

+22
-41
lines changed

3 files changed

+22
-41
lines changed

MODULE.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,11 @@ erlang_package.hex_package(
207207
version = "1.4.1",
208208
)
209209

210-
erlang_package.hex_package(
210+
erlang_package.git_package(
211211
name = "khepri",
212212
build_file = "@rabbitmq-server//bazel:BUILD.khepri",
213-
sha256 = "dccfaeb3583a04722e2258911f7f906ce67f8efac80504be4923aaafae6d4e21",
214-
version = "0.14.0",
213+
branch = "default-to-local-queries-plus-related-improvements",
214+
repository = "rabbitmq/khepri",
215215
)
216216

217217
erlang_package.hex_package(

deps/rabbit/src/rabbit_db_maintenance.erl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,7 @@ get_consistent_in_mnesia(Node) ->
155155

156156
get_consistent_in_khepri(Node) ->
157157
Path = khepri_maintenance_path(Node),
158-
%% FIXME: Ra consistent queries are fragile in the sense that the query
159-
%% function may run on a remote node and the function reference or MFA may
160-
%% not be valid on that node. That's why we force a local query for now.
161-
%Options = #{favor => consistent},
162-
Options = #{favor => local},
158+
Options = #{favor => consistency},
163159
case rabbit_khepri:get(Path, Options) of
164160
{ok, #node_maintenance_state{status = Status}} ->
165161
Status;

deps/rabbit/src/rabbit_khepri.erl

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,7 @@ wait_for_leader(_Timeout, 0) ->
281281
wait_for_leader(Timeout, Retries) ->
282282
rabbit_log:info("Waiting for Khepri leader for ~tp ms, ~tp retries left",
283283
[Timeout, Retries - 1]),
284-
Options = #{timeout => Timeout,
285-
favor => low_latency},
284+
Options = #{timeout => Timeout},
286285
case khepri:exists(?STORE_ID, [], Options) of
287286
Exists when is_boolean(Exists) ->
288287
rabbit_log:info("Khepri leader elected"),
@@ -866,50 +865,46 @@ cas(Path, Pattern, Data) ->
866865
?STORE_ID, Path, Pattern, Data, ?DEFAULT_COMMAND_OPTIONS).
867866

868867
fold(Path, Pred, Acc) ->
869-
khepri:fold(?STORE_ID, Path, Pred, Acc, #{favor => low_latency}).
868+
khepri:fold(?STORE_ID, Path, Pred, Acc).
870869

871870
fold(Path, Pred, Acc, Options) ->
872-
Options1 = Options#{favor => low_latency},
873-
khepri:fold(?STORE_ID, Path, Pred, Acc, Options1).
871+
khepri:fold(?STORE_ID, Path, Pred, Acc, Options).
874872

875873
foreach(Path, Pred) ->
876-
khepri:foreach(?STORE_ID, Path, Pred, #{favor => low_latency}).
874+
khepri:foreach(?STORE_ID, Path, Pred).
877875

878876
filter(Path, Pred) ->
879-
khepri:filter(?STORE_ID, Path, Pred, #{favor => low_latency}).
877+
khepri:filter(?STORE_ID, Path, Pred).
880878

881879
get(Path) ->
882-
khepri:get(?STORE_ID, Path, #{favor => low_latency}).
880+
khepri:get(?STORE_ID, Path).
883881

884882
get(Path, Options) ->
885-
Options1 = Options#{favor => low_latency},
886-
khepri:get(?STORE_ID, Path, Options1).
883+
khepri:get(?STORE_ID, Path, Options).
887884

888885
get_many(PathPattern) ->
889-
khepri:get_many(?STORE_ID, PathPattern, #{favor => low_latency}).
886+
khepri:get_many(?STORE_ID, PathPattern).
890887

891888
adv_get(Path) ->
892-
khepri_adv:get(?STORE_ID, Path, #{favor => low_latency}).
889+
khepri_adv:get(?STORE_ID, Path).
893890

894891
adv_get_many(PathPattern) ->
895-
khepri_adv:get_many(?STORE_ID, PathPattern, #{favor => low_latency}).
892+
khepri_adv:get_many(?STORE_ID, PathPattern).
896893

897894
match(Path) ->
898895
match(Path, #{}).
899896

900897
match(Path, Options) ->
901-
Options1 = Options#{favor => low_latency},
902-
khepri:get_many(?STORE_ID, Path, Options1).
898+
khepri:get_many(?STORE_ID, Path, Options).
903899

904-
exists(Path) -> khepri:exists(?STORE_ID, Path, #{favor => low_latency}).
900+
exists(Path) -> khepri:exists(?STORE_ID, Path).
905901

906902
list(Path) ->
907903
khepri:get_many(
908-
?STORE_ID, Path ++ [?KHEPRI_WILDCARD_STAR], #{favor => low_latency}).
904+
?STORE_ID, Path ++ [?KHEPRI_WILDCARD_STAR]).
909905

910906
list_child_nodes(Path) ->
911-
Options = #{props_to_return => [child_names],
912-
favor => low_latency},
907+
Options = #{props_to_return => [child_names]},
913908
case khepri_adv:get_many(?STORE_ID, Path, Options) of
914909
{ok, Result} ->
915910
case maps:values(Result) of
@@ -923,8 +918,7 @@ list_child_nodes(Path) ->
923918
end.
924919

925920
count_children(Path) ->
926-
Options = #{props_to_return => [child_list_length],
927-
favor => low_latency},
921+
Options = #{props_to_return => [child_list_length]},
928922
case khepri_adv:get_many(?STORE_ID, Path, Options) of
929923
{ok, Map} ->
930924
lists:sum([L || #{child_list_length := L} <- maps:values(Map)]);
@@ -975,18 +969,9 @@ transaction(Fun) ->
975969
transaction(Fun, ReadWrite) ->
976970
transaction(Fun, ReadWrite, #{}).
977971

978-
transaction(Fun, ReadWrite, Options0) ->
979-
%% If the transaction is read-only, use the same default options we use
980-
%% for most queries.
981-
DefaultQueryOptions = case ReadWrite of
982-
ro ->
983-
#{favor => low_latency};
984-
_ ->
985-
#{}
986-
end,
987-
Options1 = maps:merge(DefaultQueryOptions, Options0),
988-
Options = maps:merge(?DEFAULT_COMMAND_OPTIONS, Options1),
989-
case khepri:transaction(?STORE_ID, Fun, ReadWrite, Options) of
972+
transaction(Fun, ReadWrite, Options) ->
973+
Options1 = maps:merge(?DEFAULT_COMMAND_OPTIONS, Options),
974+
case khepri:transaction(?STORE_ID, Fun, ReadWrite, Options1) of
990975
ok -> ok;
991976
{ok, Result} -> Result;
992977
{error, Reason} -> throw({error, Reason})

0 commit comments

Comments
 (0)