Skip to content

Commit

Permalink
fix(pool): use write lock when getting health info (#7963)
Browse files Browse the repository at this point in the history
  • Loading branch information
NamanJain8 authored Jul 29, 2021
1 parent c2e1476 commit b41ff1f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions conn/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,11 @@ func (p *Pool) IsHealthy() bool {

// HealthInfo returns the healthinfo.
func (p *Pool) HealthInfo() pb.HealthInfo {
p.RLock()
defer p.RUnlock()
ok := p.IsHealthy()
p.Lock()
defer p.Unlock()
p.healthInfo.Status = "healthy"
if !p.IsHealthy() {
if !ok {
p.healthInfo.Status = "unhealthy"
}
p.healthInfo.LastEcho = p.lastEcho.Unix()
Expand Down
2 changes: 1 addition & 1 deletion worker/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type groupi struct {
var gr = &groupi{
blockDeletes: new(sync.Mutex),
tablets: make(map[string]*pb.Tablet),
closer: z.NewCloser(3), // Match CLOSER:1 in this file.
}

func groups() *groupi {
Expand Down Expand Up @@ -155,7 +156,6 @@ func StartRaftNodes(walStore *raftwal.DiskStorage, bindall bool) {
gr.Node.InitAndStartNode()
glog.Infof("Init and start Raft node: OK")

gr.closer = z.NewCloser(3) // Match CLOSER:1 in this file.
go gr.sendMembershipUpdates()
go gr.receiveMembershipUpdates()
go gr.processOracleDeltaStream()
Expand Down

0 comments on commit b41ff1f

Please sign in to comment.