Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP) Bump seshat #469

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ESCRIPT_EMU_ARGS = -noinput -setcookie ra_fifo_cli

dep_gen_batch_server = hex 0.8.8
dep_aten = hex 0.6.0
dep_seshat = hex 0.6.0
dep_seshat = git https://github.com/rabbitmq/seshat.git 2b09eab1e1ec2e97de744236fad98fdb6c3897fa
DEPS = aten gen_batch_server seshat

TEST_DEPS = proper meck eunit_formatters inet_tcp_proxy
Expand Down
3 changes: 2 additions & 1 deletion rebar.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{deps, [
{gen_batch_server, "0.8.8"},
{aten, "0.6.0"},
{seshat, "0.6.0"}
{seshat, {git, "https://github.com/rabbitmq/seshat",
{ref, "2b09eab1e1ec2e97de744236fad98fdb6c3897fa"}}}
]}.

{profiles,
Expand Down
11 changes: 6 additions & 5 deletions rebar.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{"1.2.0",
[{<<"aten">>,{pkg,<<"aten">>,<<"0.6.0">>},0},
{<<"gen_batch_server">>,{pkg,<<"gen_batch_server">>,<<"0.8.8">>},0},
{<<"seshat">>,{pkg,<<"seshat">>,<<"0.6.0">>},0}]}.
{<<"seshat">>,
{git,"https://github.com/rabbitmq/seshat",
{ref,"2b09eab1e1ec2e97de744236fad98fdb6c3897fa"}},
0}]}.
[
{pkg_hash,[
{<<"aten">>, <<"7A57B275A6DAF515AC3683FB9853E280B4D0DCDD74292FD66AC4A01C8694F8C7">>},
{<<"gen_batch_server">>, <<"7840A1FA63EE1EFFC83E8A91D22664847A2BA1192D30EAFFFD914ACB51578068">>},
{<<"seshat">>, <<"3172EB1D7A2A4F66108CD6933A4E465AFF80F84AA90ED83F047B92F636123CCD">>}]},
{<<"gen_batch_server">>, <<"7840A1FA63EE1EFFC83E8A91D22664847A2BA1192D30EAFFFD914ACB51578068">>}]},
{pkg_hash_ext,[
{<<"aten">>, <<"5F39A164206AE3F211EF5880B1F7819415686436E3229D30B6A058564FBAA168">>},
{<<"gen_batch_server">>, <<"C3E6A1A2A0FB62AEE631A98CFA0FD8903E9562422CBF72043953E2FB1D203017">>},
{<<"seshat">>, <<"7CEF700F92831DD7CAE6A6DD223CCC55AC88ECCE0631EE9AB0F2B5FB70E79B90">>}]}
{<<"gen_batch_server">>, <<"C3E6A1A2A0FB62AEE631A98CFA0FD8903E9562422CBF72043953E2FB1D203017">>}]}
].
6 changes: 6 additions & 0 deletions src/ra_counters.erl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
-export([
init/0,
new/2,
new/3,
fetch/1,
overview/0,
overview/1,
Expand All @@ -32,6 +33,11 @@ init() ->
new(Name, FieldsSpec) ->
seshat:new(ra, Name, FieldsSpec).

-spec new(name(), seshat:fields_spec(), seshat:label()) ->
counters:counters_ref().
new(Name, FieldsSpec, Label) ->
seshat:new(ra, Name, FieldsSpec, Label).

-spec fetch(name()) -> undefined | counters:counters_ref().
fetch(Name) ->
seshat:fetch(ra, Name).
Expand Down
3 changes: 3 additions & 0 deletions src/ra_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,17 @@
await_condition_timeout => non_neg_integer(),
max_pipeline_count => non_neg_integer(),
ra_event_formatter => {module(), atom(), [term()]},
%% Deprecated in favor of counter_label:
counter => counters:counters_ref(),
counter_label => seshat:label(),
membership => ra_membership(),
system_config => ra_system:config(),
has_changed => boolean()
}.

-type mutable_config() :: #{cluster_name => ra_cluster_name(),
metrics_key => term(),
counter_label => seshat:label(),
broadcast_time => non_neg_integer(), % ms
tick_timeout => non_neg_integer(), % ms
install_snap_rpc_timeout => non_neg_integer(), % ms
Expand Down
29 changes: 17 additions & 12 deletions src/ra_server_proc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,22 @@ do_init(#{id := Id,
Key = ra_lib:ra_server_id_to_local_name(Id),
true = ets:insert(ra_state, {Key, init, unknown}),
process_flag(trap_exit, true),
Config = #{counter := Counter,
system_config := SysConf} = maps:merge(config_defaults(Id),
Config0),
Config1 = #{system_config := SysConf} = maps:merge(config_defaults(),
Config0),
Counter = case maps:find(counter, Config1) of
{ok, C} ->
C;
error ->
case ra_counters:fetch(Id) of
undefined ->
Label = maps:get(counter_label, Config1, Id),
ra_counters:new(
Id, {persistent_term, ?FIELDSPEC_KEY}, Label);
C ->
C
end
end,
Config = maps:put(counter, Counter, Config1),
MsgQData = maps:get(message_queue_data, SysConf, off_heap),
MinBinVheapSize = maps:get(server_min_bin_vheap_size, SysConf,
?MIN_BIN_VHEAP_SIZE),
Expand Down Expand Up @@ -1709,20 +1722,12 @@ gen_statem_safe_call(ServerId, Msg, Timeout) ->
do_state_query(QueryName, #state{server_state = State}) ->
ra_server:state_query(QueryName, State).

config_defaults(ServerId) ->
Counter = case ra_counters:fetch(ServerId) of
undefined ->
ra_counters:new(ServerId,
{persistent_term, ?FIELDSPEC_KEY});
C ->
C
end,
config_defaults() ->
#{broadcast_time => ?DEFAULT_BROADCAST_TIME,
tick_timeout => ?TICK_INTERVAL_MS,
install_snap_rpc_timeout => ?INSTALL_SNAP_RPC_TIMEOUT,
await_condition_timeout => ?DEFAULT_AWAIT_CONDITION_TIMEOUT,
initial_members => [],
counter => Counter,
system_config => ra_system:default_config()
}.

Expand Down
Loading