@@ -1103,18 +1103,19 @@ handle_aux(_RaState, cast, eol, #?AUX{name = Name} = Aux, Log, _) ->
11031103 ets :delete (rabbit_fifo_usage , Name ),
11041104 {no_reply , Aux , Log };
11051105handle_aux (_RaState , {call , _From }, oldest_entry_timestamp , Aux ,
1106- Log , #? MODULE {} = State ) ->
1107- Ts = case smallest_raft_index (State ) of
1108- % % if there are no entries, we return current timestamp
1109- % % so that any previously obtained entries are considered older than this
1110- undefined ->
1111- erlang :system_time (millisecond );
1112- Idx when is_integer (Idx ) ->
1113- % % TODO: make more defensive to avoid potential crash
1114- {{_ , _ , {_ , Meta , _ , _ }}, _Log1 } = ra_log :fetch (Idx , Log ),
1115- #{ts := Timestamp } = Meta ,
1116- Timestamp
1117- end ,
1106+ Log0 , #? MODULE {} = State ) ->
1107+ {Ts , Log } = case smallest_raft_index (State ) of
1108+ % % if there are no entries, we return current timestamp
1109+ % % so that any previously obtained entries are considered
1110+ % % older than this
1111+ undefined ->
1112+ {erlang :system_time (millisecond ), Log0 };
1113+ Idx when is_integer (Idx ) ->
1114+ % % TODO: make more defensive to avoid potential crash
1115+ {{_ , _ , {_ , Meta , _ , _ }}, Log1 } = ra_log :fetch (Idx , Log0 ),
1116+ #{ts := Timestamp } = Meta ,
1117+ {Timestamp , Log1 }
1118+ end ,
11181119 {reply , {ok , Ts }, Aux , Log };
11191120handle_aux (_RaState , {call , _From }, {peek , Pos }, Aux0 ,
11201121 Log0 , MacState ) ->
0 commit comments