-
Notifications
You must be signed in to change notification settings - Fork 155
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
storage: Fix for leo-project/leofs#553 #948
Conversation
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.
Overall structure of code/tests LGTM. a few suggestions to improve efficiency here so please check those out.
@@ -1180,9 +1180,11 @@ get_active_redundancies(_, []) -> | |||
get_active_redundancies(Quorum, Redundancies) -> | |||
AvailableNodes = [RedundantNode || | |||
#redundant_node{available = true} = RedundantNode <- Redundancies], | |||
UnavailableNodes = [RedundantNode || | |||
#redundant_node{available = false} = RedundantNode <- Redundancies], |
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.
Why not just having the flag that indicates if there is unavailable node instead of list UnavailableNodes?
case (Quorum =< erlang:length(AvailableNodes)) of | ||
true -> | ||
{ok, AvailableNodes}; | ||
{ok, AvailableNodes, UnavailableNodes}; |
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.
As described above, just return bool (true/false) instead of list.
{error, Error}; | ||
read_and_repair_1(ReadParams, [Node|Rest], AvailableNodes, Errors) -> | ||
%%read_and_repair_1(_,[],_,[Error|_]) -> | ||
%% {error, Error}; |
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.
Remove the comment above
%%read_and_repair_1(_,[],_,[Error|_]) -> | ||
%% {error, Error}; | ||
|
||
read_and_repair_1(_,[],_,[], Errors) -> |
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.
Match against false instead of the empty list.
@@ -1200,19 +1202,34 @@ get_active_redundancies(Quorum, Redundancies) -> | |||
Cause::any()). | |||
read_and_repair(#read_parameter{quorum = Q} = ReadParams, Redundancies) -> | |||
case get_active_redundancies(Q, Redundancies) of | |||
{ok, AvailableNodes} -> | |||
read_and_repair_1(ReadParams, AvailableNodes, AvailableNodes, []); | |||
{ok, AvailableNodes, UnavailableNodes} -> |
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.
the name also should be renamed if it become the flag like HasUnavailableNodes.
a24b423
to
930b1d4
Compare
No description provided.