Skip to content
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

Extend replication when instance heartbeat timeout #4493

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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