aboutsummaryrefslogtreecommitdiff
path: root/weed/shell
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-04-23 03:32:18 -0700
committerChris Lu <chris.lu@gmail.com>2020-04-23 03:32:18 -0700
commit842e3301ee3bb72ba513454c8a68df4b6ed72849 (patch)
treef6939ec1472dd58beda258dbd3f7cebab92e0c79 /weed/shell
parent69f336e59f6e4f855bfc5c2ebf0e57413fe92961 (diff)
downloadseaweedfs-842e3301ee3bb72ba513454c8a68df4b6ed72849.tar.xz
seaweedfs-842e3301ee3bb72ba513454c8a68df4b6ed72849.zip
make second lock instant
Diffstat (limited to 'weed/shell')
-rw-r--r--weed/shell/exclusive_locker.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/weed/shell/exclusive_locker.go b/weed/shell/exclusive_locker.go
index 38f5caace..f4938d3e6 100644
--- a/weed/shell/exclusive_locker.go
+++ b/weed/shell/exclusive_locker.go
@@ -13,6 +13,7 @@ import (
const (
RenewInteval = 4 * time.Second
SafeRenewInteval = 3 * time.Second
+ InitLockInteval = 1 * time.Second
)
type ExclusiveLocker struct {
@@ -40,17 +41,15 @@ func (l *ExclusiveLocker) RequestLock() {
// retry to get the lease
for {
if err := l.masterClient.WithClient(func(client master_pb.SeaweedClient) error {
- resp, err := client.LeaseAdminToken(context.Background(), &master_pb.LeaseAdminTokenRequest{
- PreviousToken: atomic.LoadInt64(&l.token),
- PreviousLockTime: atomic.LoadInt64(&l.lockTsNs),
- })
+ resp, err := client.LeaseAdminToken(context.Background(), &master_pb.LeaseAdminTokenRequest{})
if err == nil {
atomic.StoreInt64(&l.token, resp.Token)
atomic.StoreInt64(&l.lockTsNs, resp.LockTsNs)
}
return err
}); err != nil {
- time.Sleep(RenewInteval)
+ // println("leasing problem", err.Error())
+ time.Sleep(InitLockInteval)
} else {
break
}
@@ -93,4 +92,6 @@ func (l *ExclusiveLocker) ReleaseLock() {
})
return nil
})
+ atomic.StoreInt64(&l.token, 0)
+ atomic.StoreInt64(&l.lockTsNs, 0)
}