Skip to content

Commit

Permalink
extend_replication_when_instance_heartbeat_timeout
Browse files Browse the repository at this point in the history
Signed-off-by: lanmengran1 <lanmengran1@jd.com>
  • Loading branch information
lanmengran1 committed Sep 28, 2021
1 parent 3291733 commit 975d051
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
* [BUGFIX] Querier: fixed panic when querying exemplars and using `-distributor.shard-by-all-labels=false`. #4473
* [BUGFIX] Querier: honor querier minT,maxT if `nil` SelectHints are passed to Select(). #4413
* [BUGFIX] Compactor: fixed panic while collecting Prometheus metrics. #4483
* [BUGFIX] Ring: extend replication when instance heartbeat timeoutgst. #4493


## 1.10.0 / 2021-08-03
Expand Down
9 changes: 7 additions & 2 deletions pkg/ring/ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,15 @@ func (r *Ring) Get(key uint32, op Operation, bufDescs []InstanceDesc, bufHosts,

distinctHosts = append(distinctHosts, info.InstanceID)
instance := r.ringDesc.Ingesters[info.InstanceID]

state := instance.State
// Heartbeat unhealthy instance also needs to extend replication.
// Since the ring will not update instance state automatically, changing the state to LEFT instead.
if !instance.IsHeartbeatHealthy(r.cfg.HeartbeatTimeout, time.Now()) {
state = LEFT
}
// Check whether the replica set should be extended given we're including
// this instance.
if op.ShouldExtendReplicaSetOnState(instance.State) {
if op.ShouldExtendReplicaSetOnState(state) {
n++
} else if r.cfg.ZoneAwarenessEnabled && info.Zone != "" {
// We should only add the zone if we are not going to extend,
Expand Down

0 comments on commit 975d051

Please sign in to comment.