Skip to content

Commit

Permalink
perf(release3.5): use RLock in Demoted method for read-only access to…
Browse files Browse the repository at this point in the history
… expiry
  • Loading branch information
huangzw committed Feb 18, 2025
1 parent 4fb86eb commit 8e0a08d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions server/lease/lessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ import (
"time"

"github.com/coreos/go-semver/semver"
"go.uber.org/zap"

pb "go.etcd.io/etcd/api/v3/etcdserverpb"
"go.etcd.io/etcd/server/v3/lease/leasepb"
"go.etcd.io/etcd/server/v3/mvcc/backend"
"go.etcd.io/etcd/server/v3/mvcc/buckets"
"go.uber.org/zap"
)

// NoLease is a special LeaseID representing the absence of a lease.
Expand Down Expand Up @@ -912,8 +913,8 @@ func (l *Lease) forever() {

// Demoted returns true if the lease's expiry has been reset to forever.
func (l *Lease) Demoted() bool {
l.expiryMu.Lock()
defer l.expiryMu.Unlock()
l.expiryMu.RLock()
defer l.expiryMu.RUnlock()
return l.expiry == forever
}

Expand Down

0 comments on commit 8e0a08d

Please sign in to comment.