We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c5ebfca commit fd1a3fbCopy full SHA for fd1a3fb
src/ra_log.erl
@@ -751,7 +751,13 @@ set_last_index(Idx, #?MODULE{cfg = Cfg,
751
last_written_index_term = Cur}};
752
{Term, State1} ->
753
LWIdx = min(Idx, LWIdx0),
754
- {LWTerm, State2} = fetch_term(LWIdx, State1),
+ {LWTerm, State2} = case Cur of
755
+ {LWIdx, SnapTerm} ->
756
+ {SnapTerm, State1};
757
+ _ ->
758
+ fetch_term(LWIdx, State1)
759
+ end,
760
+
761
%% this should always be found but still assert just in case
762
%% _if_ this ends up as a genuine reversal next time we try
763
%% to write to the mem table it will detect this and open
src/ra_server.erl
@@ -610,12 +610,12 @@ handle_leader({command, Cmd}, #{cfg := #cfg{id = Self,
610
State = State0#{condition =>
611
#{predicate_fun => fun wal_down_condition/2,
612
transition_to => leader,
613
- %% TODO: make duration configurable?
614
timeout => #{duration => 5000,
615
effects => CondEffs,
616
transition_to => leader}}},
617
618
- {await_condition, State, Effects0};
+ Effects = append_error_reply(Cmd, wal_down, Effects0),
+ {await_condition, State, Effects};
619
{not_appended, Reason, State, Effects0} ->
620
?WARN("~ts command ~W NOT appended to log. Reason ~w",
621
[LogId, Cmd, 10, Reason]),
test/ra_log_2_SUITE.erl
@@ -1445,9 +1445,12 @@ snapshot_installation(Config) ->
1445
% after a snapshot we need a "truncating write" that ignores missing
1446
% indexes
1447
Log5 = write_n(16, 20, 2, Log4),
1448
- {[], _} = ra_log_take(1, 9, Log5),
1449
- {[_, _], _} = ra_log_take(16, 17, Log5),
1450
- Log6 = assert_log_events(Log5, fun (L) ->
+ %% check that the log can be reset to a pending write index
+ {ok, Log5b} = ra_log:set_last_index(19, Log5),
1451
+ {[], _} = ra_log_take(1, 9, Log5b),
1452
+ {[_, _], _} = ra_log_take(16, 17, Log5b),
1453
+ Log6 = assert_log_events(Log5b, fun (L) ->
1454
{19, 2} == ra_log:last_written(L)
1455
end),
1456
{[], _} = ra_log_take(1, 9, Log6),
0 commit comments