Skip to content

Commit

Permalink
Calls Unlock explicitly after potetiantly losing it
Browse files Browse the repository at this point in the history
Signed-off-by: Rafael Chacon <[email protected]>
  • Loading branch information
rafael committed Dec 7, 2018
1 parent ccf9ef2 commit b3a9459
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion go/vt/topo/consultopo/election.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ func (mp *consulMasterParticipation) WaitForMastership() (context.Context, error
go func() {
select {
case <-lost:
// We lost the lock, nothing to do but lockCancel().
lockCancel()
// We could have lost the lock. Per consul API, explicitly call Unlock to make sure that session will not be renewed.
if err := l.Unlock(); err != nil {
log.Errorf("master election(%v) Unlock failed: %v", mp.name, err)
}
case <-mp.stop:
// Stop was called. We stop the context first,
// so the running process is not thinking it
Expand Down

0 comments on commit b3a9459

Please sign in to comment.