@@ -9,7 +9,7 @@ type ReplicationStrategy interface {
9
9
// Filter out unhealthy instances and checks if there're enough instances
10
10
// for an operation to succeed. Returns an error if there are not enough
11
11
// instances.
12
- Filter (instances []IngesterDesc , op Operation , replicationFactor int , heartbeatTimeout time.Duration ) (healthy []IngesterDesc , maxFailures int , err error )
12
+ Filter (instances []IngesterDesc , op Operation , replicationFactor int , heartbeatTimeout time.Duration , zoneAwarenessEnabled bool ) (healthy []IngesterDesc , maxFailures int , err error )
13
13
14
14
// ShouldExtendReplicaSet returns true if given an instance that's going to be
15
15
// added to the replica set, the replica set size should be extended by 1
@@ -25,7 +25,7 @@ type DefaultReplicationStrategy struct{}
25
25
// - Filters out dead ingesters so the one doesn't even try to write to them.
26
26
// - Checks there is enough ingesters for an operation to succeed.
27
27
// The ingesters argument may be overwritten.
28
- func (s * DefaultReplicationStrategy ) Filter (ingesters []IngesterDesc , op Operation , replicationFactor int , heartbeatTimeout time.Duration ) ([]IngesterDesc , int , error ) {
28
+ func (s * DefaultReplicationStrategy ) Filter (ingesters []IngesterDesc , op Operation , replicationFactor int , heartbeatTimeout time.Duration , zoneAwarenessEnabled bool ) ([]IngesterDesc , int , error ) {
29
29
// We need a response from a quorum of ingesters, which is n/2 + 1. In the
30
30
// case of a node joining/leaving, the actual replica set might be bigger
31
31
// than the replication factor, so use the bigger or the two.
@@ -49,8 +49,14 @@ func (s *DefaultReplicationStrategy) Filter(ingesters []IngesterDesc, op Operati
49
49
// This is just a shortcut - if there are not minSuccess available ingesters,
50
50
// after filtering out dead ones, don't even bother trying.
51
51
if len (ingesters ) < minSuccess {
52
- err := fmt .Errorf ("at least %d live replicas required, could only find %d" ,
53
- minSuccess , len (ingesters ))
52
+ var err error
53
+
54
+ if zoneAwarenessEnabled {
55
+ err = fmt .Errorf ("at least %d live replicas required across different availability zones, could only find %d" , minSuccess , len (ingesters ))
56
+ } else {
57
+ err = fmt .Errorf ("at least %d live replicas required, could only find %d" , minSuccess , len (ingesters ))
58
+ }
59
+
54
60
return nil , 0 , err
55
61
}
56
62
0 commit comments