From e5eca1c5a47755758bb6ace6cfeed50e1a5d0e2b Mon Sep 17 00:00:00 2001 From: Philip Kuryloski Date: Fri, 10 Dec 2021 13:17:31 +0100 Subject: Return `none` as the oldest message timestamp for empty queues instead of the current time --- deps/rabbit/src/rabbit_fifo.erl | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/deps/rabbit/src/rabbit_fifo.erl b/deps/rabbit/src/rabbit_fifo.erl index e7efb21f61..84520548d3 100644 --- a/deps/rabbit/src/rabbit_fifo.erl +++ b/deps/rabbit/src/rabbit_fifo.erl @@ -807,17 +807,14 @@ handle_aux(_RaState, cast, eol, #aux{name = Name} = Aux, Log, _) -> {no_reply, Aux, Log}; handle_aux(_RaState, {call, _From}, oldest_entry_timestamp, Aux, Log, #?MODULE{ra_indexes = Indexes}) -> - Ts = case rabbit_fifo_index:smallest(Indexes) of - %% if there are no entries, we return current timestamp - %% so that any previously obtained entries are considered older than this + case rabbit_fifo_index:smallest(Indexes) of undefined -> - erlang:system_time(millisecond); + {reply, {ok, none}, Aux, Log}; Idx when is_integer(Idx) -> {{_, _, {_, Meta, _, _}}, _Log1} = ra_log:fetch(Idx, Log), #{ts := Timestamp} = Meta, - Timestamp - end, - {reply, {ok, Ts}, Aux, Log}; + {reply, {ok, Timestamp}, Aux, Log} + end; handle_aux(_RaState, {call, _From}, {peek, Pos}, Aux0, Log0, MacState) -> case rabbit_fifo:query_peek(Pos, MacState) of -- cgit v1.2.1