Fix lock rpc server maintenance loop go-routine leak (#5423)

The problem was after the globalServiceDoneCh receives a
message, we cleanly stop the ticker as expected. But the
go-routine where the `select` loop is running is never
returned from. The stage at which point this may occur
i.e server is being restarted, doesn't seriously affect
servers usage. But any build up like this on server has
consequences as the new functionality would come in future.
master
Harshavardhana 7 years ago committed by kannappanr
parent 1c3f55ff64
commit b6e4f053a3
  1. 7
      cmd/lock-rpc-server.go

@ -76,11 +76,12 @@ func startLockMaintenance(lockServers []*lockServer) {
for {
// Verifies every minute for locks held more than 2minutes.
select {
case <-ticker.C:
lk.lockMaintenance(lockValidityCheckInterval)
case <-globalServiceDoneCh:
// Stop the timer.
// Stop the timer upon service closure and cleanup the go-routine.
ticker.Stop()
return
case <-ticker.C:
lk.lockMaintenance(lockValidityCheckInterval)
}
}
}(locker)

Loading…
Cancel
Save