Skip to content

Commit 38ea3fe

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 3a0808c commit 38ea3fe

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
@@ -292,8 +292,7 @@ wait_for_leader(_Timeout, 0) ->
292292
wait_for_leader(Timeout, Retries) ->
293293
rabbit_log:info("Waiting for Khepri leader for ~tp ms, ~tp retries left",
294294
[Timeout, Retries - 1]),
295-
Options = #{timeout => Timeout,
296-
favor => low_latency},
295+
Options = #{timeout => Timeout},
297296
case khepri:exists(?STORE_ID, [], Options) of
298297
Exists when is_boolean(Exists) ->
299298
rabbit_log:info("Khepri leader elected"),
@@ -877,50 +876,46 @@ cas(Path, Pattern, Data) ->
877876
?STORE_ID, Path, Pattern, Data, ?DEFAULT_COMMAND_OPTIONS).
878877

879878
fold(Path, Pred, Acc) ->
880-
khepri:fold(?STORE_ID, Path, Pred, Acc, #{favor => low_latency}).
879+
khepri:fold(?STORE_ID, Path, Pred, Acc).
881880

882881
fold(Path, Pred, Acc, Options) ->
883-
Options1 = Options#{favor => low_latency},
884-
khepri:fold(?STORE_ID, Path, Pred, Acc, Options1).
882+
khepri:fold(?STORE_ID, Path, Pred, Acc, Options).
885883

886884
foreach(Path, Pred) ->
887-
khepri:foreach(?STORE_ID, Path, Pred, #{favor => low_latency}).
885+
khepri:foreach(?STORE_ID, Path, Pred).
888886

889887
filter(Path, Pred) ->
890-
khepri:filter(?STORE_ID, Path, Pred, #{favor => low_latency}).
888+
khepri:filter(?STORE_ID, Path, Pred).
891889

892890
get(Path) ->
893-
khepri:get(?STORE_ID, Path, #{favor => low_latency}).
891+
khepri:get(?STORE_ID, Path).
894892

895893
get(Path, Options) ->
896-
Options1 = Options#{favor => low_latency},
897-
khepri:get(?STORE_ID, Path, Options1).
894+
khepri:get(?STORE_ID, Path, Options).
898895

899896
get_many(PathPattern) ->
900-
khepri:get_many(?STORE_ID, PathPattern, #{favor => low_latency}).
897+
khepri:get_many(?STORE_ID, PathPattern).
901898

902899
adv_get(Path) ->
903-
khepri_adv:get(?STORE_ID, Path, #{favor => low_latency}).
900+
khepri_adv:get(?STORE_ID, Path).
904901

905902
adv_get_many(PathPattern) ->
906-
khepri_adv:get_many(?STORE_ID, PathPattern, #{favor => low_latency}).
903+
khepri_adv:get_many(?STORE_ID, PathPattern).
907904

908905
match(Path) ->
909906
match(Path, #{}).
910907

911908
match(Path, Options) ->
912-
Options1 = Options#{favor => low_latency},
913-
khepri:get_many(?STORE_ID, Path, Options1).
909+
khepri:get_many(?STORE_ID, Path, Options).
914910

915-
exists(Path) -> khepri:exists(?STORE_ID, Path, #{favor => low_latency}).
911+
exists(Path) -> khepri:exists(?STORE_ID, Path).
916912

917913
list(Path) ->
918914
khepri:get_many(
919-
?STORE_ID, Path ++ [?KHEPRI_WILDCARD_STAR], #{favor => low_latency}).
915+
?STORE_ID, Path ++ [?KHEPRI_WILDCARD_STAR]).
920916

921917
list_child_nodes(Path) ->
922-
Options = #{props_to_return => [child_names],
923-
favor => low_latency},
918+
Options = #{props_to_return => [child_names]},
924919
case khepri_adv:get_many(?STORE_ID, Path, Options) of
925920
{ok, Result} ->
926921
case maps:values(Result) of
@@ -934,8 +929,7 @@ list_child_nodes(Path) ->
934929
end.
935930

936931
count_children(Path) ->
937-
Options = #{props_to_return => [child_list_length],
938-
favor => low_latency},
932+
Options = #{props_to_return => [child_list_length]},
939933
case khepri_adv:get_many(?STORE_ID, Path, Options) of
940934
{ok, Map} ->
941935
lists:sum([L || #{child_list_length := L} <- maps:values(Map)]);
@@ -986,18 +980,9 @@ transaction(Fun) ->
986980
transaction(Fun, ReadWrite) ->
987981
transaction(Fun, ReadWrite, #{}).
988982

989-
transaction(Fun, ReadWrite, Options0) ->
990-
%% If the transaction is read-only, use the same default options we use
991-
%% for most queries.
992-
DefaultQueryOptions = case ReadWrite of
993-
ro ->
994-
#{favor => low_latency};
995-
_ ->
996-
#{}
997-
end,
998-
Options1 = maps:merge(DefaultQueryOptions, Options0),
999-
Options = maps:merge(?DEFAULT_COMMAND_OPTIONS, Options1),
1000-
case khepri:transaction(?STORE_ID, Fun, ReadWrite, Options) of
983+
transaction(Fun, ReadWrite, Options) ->
984+
Options1 = maps:merge(?DEFAULT_COMMAND_OPTIONS, Options),
985+
case khepri:transaction(?STORE_ID, Fun, ReadWrite, Options1) of
1001986
ok -> ok;
1002987
{ok, Result} -> Result;
1003988
{error, Reason} -> throw({error, Reason})

0 commit comments

Comments
 (0)