Skip to content

Commit

Permalink
Merge pull request #4689 from HubSpot/heartbeat-fix
Browse files Browse the repository at this point in the history
Don't return cached heartbeat read when query service is down to avoi…
  • Loading branch information
sougou authored Mar 12, 2019
2 parents 447c36c + 0d01465 commit d3d4ea4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions go/vt/vttablet/heartbeat/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,7 @@ func (r *Reader) recordError(err error) {
r.errorLog.Errorf("%v", err)
readErrors.Add(1)
}

func (r *Reader) IsOpen() bool {
return r.isOpen
}
8 changes: 8 additions & 0 deletions go/vt/vttablet/tabletserver/tabletserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1866,6 +1866,14 @@ func (tsv *TabletServer) BroadcastHealth(terTimestamp int64, stats *querypb.Real
// HeartbeatLag returns the current lag as calculated by the heartbeat
// package, if heartbeat is enabled. Otherwise returns 0.
func (tsv *TabletServer) HeartbeatLag() (time.Duration, error) {
// If the reader is closed and we are not serving, then the
// query service is shutdown and this value is not being updated.
// We return healthy from this as a signal to the healtcheck to attempt
// to start the query service again. If the query service fails to start
// with an error, then that error is be reported by the healthcheck.
if !tsv.hr.IsOpen() && !tsv.IsServing() {
return 0, nil
}
return tsv.hr.GetLatest()
}

Expand Down

0 comments on commit d3d4ea4

Please sign in to comment.