-
Notifications
You must be signed in to change notification settings - Fork 4k
Ensure only alive leaders and followers when fetching QQ replica states #12709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
4914850
4e2c62b
19cc2d0
ebc0387
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -442,17 +442,25 @@ become_leader0(QName, Name) -> | |
| all_replica_states() -> | ||
| Rows0 = ets:tab2list(ra_state), | ||
| Rows = lists:map(fun | ||
| ({K, follower, promotable}) -> | ||
| {K, promotable}; | ||
| ({K, follower, non_voter}) -> | ||
| {K, non_voter}; | ||
| ({K, S, _}) -> | ||
| %% voter or unknown | ||
| {K, S}; | ||
| (T) -> | ||
| T | ||
| (T = {K, _, _}) -> | ||
| case rabbit_process:is_registered_process_alive(K) of | ||
| true -> | ||
| to_replica_state(T); | ||
| false -> | ||
| [] | ||
|
||
| end; | ||
| (_T) -> | ||
| [] | ||
| end, Rows0), | ||
| {node(), maps:from_list(Rows)}. | ||
| {node(), maps:from_list(lists:flatten(Rows))}. | ||
|
|
||
| to_replica_state({K, follower, promotable}) -> | ||
| {K, promotable}; | ||
| to_replica_state({K, follower, non_voter}) -> | ||
| {K, non_voter}; | ||
| to_replica_state({K, S, _}) -> | ||
| %% voter or unknown | ||
| {K, S}. | ||
|
|
||
| -spec list_with_minimum_quorum() -> [amqqueue:amqqueue()]. | ||
| list_with_minimum_quorum() -> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whereis/1will do here, you are already on the node where the process is running.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, i avoided the
rabbit_process:is_process_alive/1which does the extra distribution work. But also noticed we haverabbit_process:is_registered_process_alive/1which is already doingwhereis/1withis_pid/1guard check on the local node, which i'd still have to do on the case statement. seems to be doing same thing (if i'm seeing correct)Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure using a helper function for the above is worth it, just causes read indirection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
k cool, definitely easier to read. sorry for the back-&-forth on this small item (tendency has been check/use rabbit helpers 1st 😊 after finding myself rewriting some existing utils in the past 😅 ). Yep, the read indirection not necessary here 👍