Skip to content

Commit 60364f4

Browse files
committed
Fix last_index counter lag
When the leader is writing a low priority command it updated the last_index counter to the last index not the index it just wrote.
1 parent 31ea86c commit 60364f4

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/ra_log.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ append({Idx, Term, _Cmd} = Entry,
398398
when Idx =:= LastIdx + 1 ->
399399
case ra_mt:stage(Entry, Mt0) of
400400
{ok, Mt} ->
401-
put_counter(Cfg, ?C_RA_SVR_METRIC_LAST_INDEX, LastIdx),
401+
put_counter(Cfg, ?C_RA_SVR_METRIC_LAST_INDEX, Idx),
402402
State#?MODULE{last_index = Idx,
403403
last_term = Term,
404404
mem_table = Mt};

test/ra_SUITE.erl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ pipeline_commands(Config) ->
160160
%% here we are asserting on the order of received
161161
%% correlations
162162
[{C1, 15}, {C2, 20}] = gather_applied([], 125),
163+
?assertMatch(#{last_index := I,
164+
last_applied := I,
165+
last_written_index := I,
166+
commit_index := I}, ra:key_metrics(N1)),
163167
terminate_cluster([N1]).
164168

165169
stop_server_idemp(Config) ->

0 commit comments

Comments
 (0)