diff --git a/src/ra.hrl b/src/ra.hrl index 14503d48..2d6856f5 100644 --- a/src/ra.hrl +++ b/src/ra.hrl @@ -253,6 +253,7 @@ -define(C_RA_SRV_AER_RECEIVED_FOLLOWER_EMPTY, ?C_RA_LOG_RESERVED + 17). -define(C_RA_SRV_TERM_AND_VOTED_FOR_UPDATES, ?C_RA_LOG_RESERVED + 18). -define(C_RA_SRV_LOCAL_QUERIES, ?C_RA_LOG_RESERVED + 19). +-define(C_RA_SRV_INVALID_REPLY_MODE_COMMANDS, ?C_RA_LOG_RESERVED + 20). -define(RA_SRV_COUNTER_FIELDS, @@ -294,7 +295,9 @@ {term_and_voted_for_updates, ?C_RA_SRV_TERM_AND_VOTED_FOR_UPDATES, counter, "Total number of updates of term and voted for"}, {local_queries, ?C_RA_SRV_LOCAL_QUERIES, counter, - "Total number of local queries"} + "Total number of local queries"}, + {invalid_reply_mode_commands, ?C_RA_SRV_INVALID_REPLY_MODE_COMMANDS, counter, + "Total number of commands received with an invalid reply-mode"} ]). -define(RA_COUNTER_FIELDS, ?RA_LOG_COUNTER_FIELDS ++ ?RA_SRV_COUNTER_FIELDS). diff --git a/src/ra_server_proc.erl b/src/ra_server_proc.erl index adec4611..72de91d1 100644 --- a/src/ra_server_proc.erl +++ b/src/ra_server_proc.erl @@ -353,7 +353,7 @@ leader(EventType, {local_call, Msg}, State) -> leader(EventType, {leader_cast, Msg}, State) -> leader(EventType, Msg, State); leader(EventType, {command, normal, {CmdType, Data, ReplyMode}}, - #state{server_state = ServerState0} = State0) -> + #state{conf = Conf, server_state = ServerState0} = State0) -> case validate_reply_mode(ReplyMode) of ok -> %% normal priority commands are written immediately @@ -365,6 +365,7 @@ leader(EventType, {command, normal, {CmdType, Data, ReplyMode}}, State0#state{server_state = ServerState}), {keep_state, State, Actions}; Error -> + ok = incr_counter(Conf, ?C_RA_SRV_INVALID_REPLY_MODE_COMMANDS, 1), case EventType of {call, From} -> {keep_state, State0, [{reply, From, Error}]}; @@ -373,7 +374,7 @@ leader(EventType, {command, normal, {CmdType, Data, ReplyMode}}, end end; leader(EventType, {command, low, {CmdType, Data, ReplyMode}}, - #state{delayed_commands = Delayed} = State0) -> + #state{conf = Conf, delayed_commands = Delayed} = State0) -> case validate_reply_mode(ReplyMode) of ok -> %% cache the low priority command until the flush_commands message @@ -395,6 +396,7 @@ leader(EventType, {command, low, {CmdType, Data, ReplyMode}}, State = State0#state{delayed_commands = queue:in(Cmd, Delayed)}, {keep_state, State, []}; Error -> + ok = incr_counter(Conf, ?C_RA_SRV_INVALID_REPLY_MODE_COMMANDS, 1), case EventType of {call, From} -> {keep_state, State0, [{reply, From, Error}]};