Skip to content

Commit ef9497e

Browse files
committed
raft info
1 parent a8d848f commit ef9497e

File tree

4 files changed

+117
-7
lines changed

4 files changed

+117
-7
lines changed

deps/rabbit/src/rabbit_fifo.erl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,9 +1029,10 @@ handle_aux(_RaftState, cast, {#return{msg_ids = MsgIds,
10291029
%% for returns with a delivery limit set we can just return as before
10301030
{no_reply, Aux0, RaAux0, [{append, Ret, {notify, Corr, Pid}}]}
10311031
end;
1032-
handle_aux(leader, _, {handle_tick, [QName, Overview0, Nodes]},
1032+
handle_aux(leader, _, {handle_tick, [QName, MacOverview0, Nodes]},
10331033
#?AUX{tick_pid = Pid} = Aux, RaAux) ->
1034-
Overview = Overview0#{members_info => ra_aux:members_info(RaAux)},
1034+
Overview = MacOverview0#{members_info => ra_aux:members_info(RaAux),
1035+
ra_overview => ra_aux:overview(RaAux)},
10351036
NewPid =
10361037
case process_is_alive(Pid) of
10371038
false ->

deps/rabbit/src/rabbit_quorum_queue.erl

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -560,12 +560,29 @@ handle_tick(QName,
560560
num_discarded := NumDiscarded,
561561
num_discard_checked_out := NumDiscardedCheckedOut,
562562
discard_message_bytes := DiscardBytes,
563-
discard_checkout_message_bytes := DiscardCheckoutBytes,
564-
smallest_raft_index := _} = Overview,
565-
Nodes) ->
563+
discard_checkout_message_bytes := DiscardCheckoutBytes
564+
} = Overview,
565+
KnownNodes) ->
566566
%% this makes calls to remote processes so cannot be run inside the
567567
%% ra server
568568
Self = self(),
569+
MembersInfo0 = maps:get(members_info, Overview, #{}),
570+
RaOverview0 = maps:get(ra_overview, Overview, #{}),
571+
RaOverview = maps:update_with(log,
572+
fun (L) ->
573+
maps:with([last_index,
574+
first_index,
575+
last_written_index,
576+
last_wal_write,
577+
lastest_checkpoint_index],
578+
case L of
579+
#{last_written_index_term := {I, _}} = LO ->
580+
LO#{last_written_index => I};
581+
LO ->
582+
LO
583+
end)
584+
end, #{}, RaOverview0),
585+
569586
spawn(
570587
fun() ->
571588
try
@@ -600,6 +617,17 @@ handle_tick(QName,
600617
end, info(Q, Keys), Overview),
601618
MsgBytesDiscarded = DiscardBytes + DiscardCheckoutBytes,
602619
MsgBytes = EnqueueBytes + CheckoutBytes + MsgBytesDiscarded,
620+
MembersInfo = maps:fold(fun
621+
({_, N}, Val0, Acc) ->
622+
Val = maps:map(
623+
fun (status, {S, _}) ->
624+
S;
625+
(_K, V) ->
626+
V
627+
end, Val0),
628+
Acc#{N => Val}
629+
end, #{}, MembersInfo0),
630+
603631
Infos = [{consumers, NumConsumers},
604632
{publishers, NumEnqueuers},
605633
{consumer_capacity, Util},
@@ -620,7 +648,12 @@ handle_tick(QName,
620648
unlimited;
621649
Limit ->
622650
Limit
623-
end}
651+
end},
652+
{members_info, MembersInfo},
653+
{raft, maps:with([current_term,
654+
commit_index,
655+
last_applied,
656+
log], RaOverview)}
624657
| Infos0],
625658
rabbit_core_metrics:queue_stats(QName, Infos),
626659
ok = repair_leader_record(Q, Self),
@@ -631,7 +664,7 @@ handle_tick(QName,
631664
rabbit_log:debug("Repaired quorum queue ~ts amqqueue record", [rabbit_misc:rs(QName)])
632665
end,
633666
ExpectedNodes = rabbit_nodes:list_members(),
634-
case Nodes -- ExpectedNodes of
667+
case KnownNodes -- ExpectedNodes of
635668
[] ->
636669
ok;
637670
Stale when length(ExpectedNodes) > 0 ->

deps/rabbitmq_management/priv/www/js/tmpl/queue.ejs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,17 @@
421421
</div>
422422
<% } %>
423423

424+
<% if(is_quorum(queue) && queue.hasOwnProperty('raft')) { %>
425+
<div class="section-hidden">
426+
<h2 class="updatable">Raft Info (Advanced) </h2>
427+
<div class="hider updatable">
428+
<%= format('quorum-members-info', {'mode': 'queue',
429+
'queue': queue,
430+
'members_info': queue.members_info}) %>
431+
</div>
432+
</div>
433+
<% } %>
434+
424435
<% if(queue.reductions || queue.garbage_collection) { %>
425436
<div class="section-hidden">
426437
<h2>Runtime Metrics (Advanced)</h2>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<% if (members_info) {
2+
var i = 0;
3+
var r = queue.raft;
4+
var l = r.log;
5+
delete members_info[queue.leader];
6+
%>
7+
<h3>Leader</h3>
8+
<table class="list">
9+
<thead>
10+
<tr>
11+
<th>Node</th>
12+
<th>Term</th>
13+
<th>First Index</th>
14+
<th>Last Index</th>
15+
<th>Log Length</th>
16+
<th>Last Applied</th>
17+
<th>Commit Index</th>
18+
</tr>
19+
</thead>
20+
<tr>
21+
<td><%= fmt_string(queue.leader) %></td>
22+
<td><%= fmt_string(r.current_term) %></td>
23+
<td><%= fmt_string(l.first_index) %></td>
24+
<td><%= fmt_string(l.last_index) %></td>
25+
<td><%= fmt_string(l.last_index - l.first_index + 1) %></td>
26+
<td><%= fmt_string(r.last_applied) %></td>
27+
<td><%= fmt_string(r.commit_index) %></td>
28+
</tr>
29+
30+
</table>
31+
<h3>Followers </h3>
32+
<table class="list">
33+
<thead>
34+
<tr>
35+
<th>Node</th>
36+
<th>Status</th>
37+
<th>Next Index</th>
38+
<th>Match Index</th>
39+
<th>Lag</th>
40+
<th>Commit Index Sent</th>
41+
<th>Voter Status</th>
42+
</tr>
43+
</thead>
44+
<% for (var node in members_info) {
45+
i++;
46+
var m = members_info[node];
47+
%>
48+
<tr<%= alt_rows(i) %>>
49+
<td><%= fmt_string(node) %></td>
50+
<td><%= fmt_string(m.status) %></td>
51+
<td><%= fmt_string(m.next_index) %></td>
52+
<td><%= fmt_string(m.match_index) %></td>
53+
<td><%= fmt_string(l.last_index - Math.max(l.first_index, m.match_index)) %></td>
54+
<% if(m.hasOwnProperty('commit_index_sent')) { %>
55+
<td><%= fmt_string(m.commit_index_sent) %></td>
56+
<% } else { %>
57+
<td><%= fmt_string("n/a") %></td>
58+
<% } %>
59+
<td><%= fmt_string(m.voter_status.membership) %></td>
60+
</tr>
61+
<% } %>
62+
</table>
63+
<% } else { %>
64+
<p>... no info ...</p>
65+
<% } %>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy