|
|
@@ -28,7 +28,7 @@ func TryGetDistributedLock(lockKey, requestId string, isNegative bool) bool { |
|
|
|
if retry > 99 { |
|
|
|
return false |
|
|
|
} |
|
|
|
time.Sleep(time.Millisecond * time.Duration(rand.Intn(1000))) |
|
|
|
time.Sleep(time.Millisecond * time.Duration(rand.Intn(100))) |
|
|
|
retry += 1 |
|
|
|
} |
|
|
|
} else { // 只尝试一次 |
|
|
@@ -73,7 +73,7 @@ func HandleDistributedLock(masterId, requestIdPrefix string) (cb func(), err err |
|
|
|
requestId := GetDistributedLockRequestId(requestIdPrefix) |
|
|
|
balanceLockOk := TryGetDistributedLock(balanceLockKey, requestId, true) |
|
|
|
if !balanceLockOk { |
|
|
|
return nil, errors.New("系统繁忙,请稍后再试") |
|
|
|
return nil, errors.New("获取价格系统繁忙,请稍后再试") |
|
|
|
} |
|
|
|
|
|
|
|
cb = func() { |
|
|
|