shell: show which server holds the lock

fix https://github.com/chrislusf/seaweedfs/issues/1983
This commit is contained in:
Chris Lu
2021-04-22 23:56:35 -07:00
parent 89eb9f6e70
commit f0ad172e80
5 changed files with 128 additions and 109 deletions

View File

@@ -41,7 +41,7 @@ func (l *ExclusiveLocker) GetToken() (token int64, lockTsNs int64) {
return atomic.LoadInt64(&l.token), atomic.LoadInt64(&l.lockTsNs)
}
func (l *ExclusiveLocker) RequestLock() {
func (l *ExclusiveLocker) RequestLock(clientName string) {
if l.isLocking {
return
}
@@ -56,6 +56,7 @@ func (l *ExclusiveLocker) RequestLock() {
PreviousToken: atomic.LoadInt64(&l.token),
PreviousLockTime: atomic.LoadInt64(&l.lockTsNs),
LockName: AdminLockName,
ClientName: clientName,
})
if err == nil {
atomic.StoreInt64(&l.token, resp.Token)
@@ -63,7 +64,7 @@ func (l *ExclusiveLocker) RequestLock() {
}
return err
}); err != nil {
// println("leasing problem", err.Error())
println("lock:", err.Error())
time.Sleep(InitLockInteval)
} else {
break
@@ -83,6 +84,7 @@ func (l *ExclusiveLocker) RequestLock() {
PreviousToken: atomic.LoadInt64(&l.token),
PreviousLockTime: atomic.LoadInt64(&l.lockTsNs),
LockName: AdminLockName,
ClientName: clientName,
})
if err == nil {
atomic.StoreInt64(&l.token, resp.Token)