diff options
author | Michael Klishin <klishinm@vmware.com> | 2021-07-21 19:04:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-21 19:04:58 +0300 |
commit | 2d8aad78bf61a8a1664a33ce608bb780b70fec1d (patch) | |
tree | 32c199938f7a063125fe930c79d5159389855e0a | |
parent | 313410f5f4cea40cbd8f863395913d37ec519a4c (diff) | |
parent | a0ad332727a936c7be3a88f4409afe8a4293e361 (diff) | |
download | rabbitmq-server-git-2d8aad78bf61a8a1664a33ce608bb780b70fec1d.tar.gz |
Merge pull request #3216 from rabbitmq/mk-quorum-queue-oldest-known-message-command
New aux quorum queue command: oldest_entry_timestamp
-rw-r--r-- | deps/rabbit/src/rabbit_fifo.erl | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/deps/rabbit/src/rabbit_fifo.erl b/deps/rabbit/src/rabbit_fifo.erl index db43680bae..d932d20ebb 100644 --- a/deps/rabbit/src/rabbit_fifo.erl +++ b/deps/rabbit/src/rabbit_fifo.erl @@ -800,6 +800,19 @@ handle_aux(_RaState, cast, tick, #aux{name = Name, handle_aux(_RaState, cast, eol, #aux{name = Name} = Aux, Log, _) -> ets:delete(rabbit_fifo_usage, Name), {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 + undefined -> + erlang:system_time(millisecond); + Idx when is_integer(Idx) -> + {{_, _, {_, Meta, _, _}}, _Log1} = ra_log:fetch(Idx, Log), + #{ts := Timestamp} = Meta, + Timestamp + end, + {reply, {ok, Ts}, Aux, Log}; handle_aux(_RaState, {call, _From}, {peek, Pos}, Aux0, Log0, MacState) -> case rabbit_fifo:query_peek(Pos, MacState) of |