-
Notifications
You must be signed in to change notification settings - Fork 9.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lease: guard 'Lease.itemSet' from concurrent writes #7457
Conversation
lease/lessor.go
Outdated
@@ -515,6 +520,9 @@ func (l *Lease) expired() bool { | |||
} | |||
|
|||
func (l *Lease) persistTo(b backend.Backend) { | |||
l.mu.RLock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't need to be acquired since not touching itemSet?
lease/lessor.go
Outdated
@@ -530,12 +538,15 @@ func (l *Lease) persistTo(b backend.Backend) { | |||
|
|||
// TTL returns the TTL of the Lease. | |||
func (l *Lease) TTL() int64 { | |||
return l.ttl | |||
l.mu.RLock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't need to be acquired since not touching itemSet?
lease/lessor.go
Outdated
@@ -501,6 +505,7 @@ func (le *lessor) initAndRecover() { | |||
} | |||
|
|||
type Lease struct { | |||
mu sync.RWMutex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// mu protects concurrent accesses to itemSet
?
lease/lessor_test.go
Outdated
} | ||
|
||
<-donec | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wg.Wait()
?
lease/lessor.go
Outdated
} | ||
|
||
// refresh refreshes the expiry of the lease. | ||
func (l *Lease) refresh(extend time.Duration) { | ||
t := monotime.Now().Add(extend + time.Duration(l.ttl)*time.Second) | ||
t := monotime.Now().Add(extend + time.Duration(l.TTL())*time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can stay the same?
@heyitsanthony Yeah fixed it to only protect |
lgtm. Thanks! |
change this
to
|
Fix etcd-io#7448. Affected if etcd builds with Go 1.8+. Signed-off-by: Gyu-Ho Lee <[email protected]>
lgtm thanks! |
Fix #7448.
Affected if etcd builds with Go 1.8+.