Skip to content

Commit

Permalink
This is an automated cherry-pick of tikv#6636
Browse files Browse the repository at this point in the history
close tikv#6635

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
lhy1024 authored and ti-chi-bot committed Jun 28, 2023
1 parent cb1af02 commit 04d09da
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions server/election/leadership.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package election

import (
"context"
"sync"
"sync/atomic"

"github.com/pingcap/failpoint"
Expand Down Expand Up @@ -54,8 +55,14 @@ type Leadership struct {
leaderKey string
leaderValue string

<<<<<<< HEAD:server/election/leadership.go

Check failure on line 58 in server/election/leadership.go

View workflow job for this annotation

GitHub Actions / statics

syntax error: unexpected <<, expecting field name or embedded type
keepAliveCtx context.Context
keepAliceCancelFunc context.CancelFunc
=======

Check failure on line 61 in server/election/leadership.go

View workflow job for this annotation

GitHub Actions / statics

syntax error: unexpected ==, expecting field name or embedded type
keepAliveCtx context.Context
keepAliveCancelFunc context.CancelFunc
keepAliveCancelFuncLock sync.Mutex
>>>>>>> 3bdfef1a3 (leadership: avoid potential data race (#6636)):pkg/election/leadership.go

Check failure on line 65 in server/election/leadership.go

View workflow job for this annotation

GitHub Actions / statics

syntax error: unexpected >>, expecting field name or embedded type

Check failure on line 65 in server/election/leadership.go

View workflow job for this annotation

GitHub Actions / statics

invalid character U+0023 '#'
}

// NewLeadership creates a new Leadership.
Expand Down Expand Up @@ -137,8 +144,15 @@ func (ls *Leadership) Keep(ctx context.Context) {
if ls == nil {
return
}
<<<<<<< HEAD:server/election/leadership.go

Check failure on line 147 in server/election/leadership.go

View workflow job for this annotation

GitHub Actions / statics

syntax error: unexpected <<, expecting }
ls.keepAliveCtx, ls.keepAliceCancelFunc = context.WithCancel(ctx)
ls.getLease().KeepAlive(ls.keepAliveCtx)
=======
ls.keepAliveCancelFuncLock.Lock()
ls.keepAliveCtx, ls.keepAliveCancelFunc = context.WithCancel(ctx)
ls.keepAliveCancelFuncLock.Unlock()
go ls.getLease().KeepAlive(ls.keepAliveCtx)
>>>>>>> 3bdfef1a3 (leadership: avoid potential data race (#6636)):pkg/election/leadership.go

Check failure on line 155 in server/election/leadership.go

View workflow job for this annotation

GitHub Actions / statics

invalid character U+0023 '#'
}

// Check returns whether the leadership is still available.
Expand Down Expand Up @@ -230,8 +244,15 @@ func (ls *Leadership) Reset() {
if ls == nil || ls.getLease() == nil {
return
}
<<<<<<< HEAD:server/election/leadership.go

Check failure on line 247 in server/election/leadership.go

View workflow job for this annotation

GitHub Actions / statics

syntax error: unexpected <<, expecting }
if ls.keepAliceCancelFunc != nil {
ls.keepAliceCancelFunc()
=======
ls.keepAliveCancelFuncLock.Lock()
if ls.keepAliveCancelFunc != nil {
ls.keepAliveCancelFunc()
>>>>>>> 3bdfef1a3 (leadership: avoid potential data race (#6636)):pkg/election/leadership.go

Check failure on line 254 in server/election/leadership.go

View workflow job for this annotation

GitHub Actions / statics

invalid character U+0023 '#'
}
ls.keepAliveCancelFuncLock.Unlock()
ls.getLease().Close()
}

0 comments on commit 04d09da

Please sign in to comment.