@@ -12,8 +12,7 @@ import (
12
12
// - Checks there is enough ingesters for an operation to succeed.
13
13
// The ingesters argument may be overwritten.
14
14
func (r * Ring ) replicationStrategy (ingesters []IngesterDesc , op Operation ) (
15
- liveIngesters []IngesterDesc , maxFailure int , err error ,
16
- ) {
15
+ []IngesterDesc , int , error ) {
17
16
// We need a response from a quorum of ingesters, which is n/2 + 1. In the
18
17
// case of a node joining/leaving, the actual replica set might be bigger
19
18
// than the replication factor, so use the bigger or the two.
@@ -22,7 +21,7 @@ func (r *Ring) replicationStrategy(ingesters []IngesterDesc, op Operation) (
22
21
replicationFactor = len (ingesters )
23
22
}
24
23
minSuccess := (replicationFactor / 2 ) + 1
25
- maxFailure = replicationFactor - minSuccess
24
+ maxFailure : = replicationFactor - minSuccess
26
25
27
26
// Skip those that have not heartbeated in a while. NB these are still
28
27
// included in the calculation of minSuccess, so if too many failed ingesters
@@ -35,17 +34,16 @@ func (r *Ring) replicationStrategy(ingesters []IngesterDesc, op Operation) (
35
34
maxFailure --
36
35
}
37
36
}
38
- liveIngesters = ingesters
39
37
40
38
// This is just a shortcut - if there are not minSuccess available ingesters,
41
39
// after filtering out dead ones, don't even bother trying.
42
- if maxFailure < 0 || len (liveIngesters ) < minSuccess {
43
- err = fmt .Errorf ("at least %d live ingesters required, could only find %d" ,
44
- minSuccess , len (liveIngesters ))
45
- return
40
+ if maxFailure < 0 || len (ingesters ) < minSuccess {
41
+ err : = fmt .Errorf ("at least %d live ingesters required, could only find %d" ,
42
+ minSuccess , len (ingesters ))
43
+ return nil , 0 , err
46
44
}
47
45
48
- return
46
+ return ingesters , maxFailure , nil
49
47
}
50
48
51
49
// IsHealthy checks whether an ingester appears to be alive and heartbeating
0 commit comments