Compare commits

..
Author SHA1 Message Date
copilot-swe-agent[bot] 3134e4112d Initial plan 2025-12-20 22:47:06 +00:00
Chris Lu e7fe274e17 Make lock_manager.RenewInterval configurable in LiveLock
- Add renewInterval field to LiveLock struct
- Modify StartLongLivedLock to accept renewInterval parameter
- Update all call sites to pass lock_manager.RenewInterval
- Default to lock_manager.RenewInterval if zero is passed
2025-12-20 14:42:39 -08:00
4 changed files with 9 additions and 10 deletions
+4 -5
View File
@@ -61,11 +61,7 @@ func (lc *LockClient) NewShortLivedLock(key string, owner string) (lock *LiveLoc
}
// StartLongLivedLock starts a goroutine to lock the key and returns immediately.
func (lc *LockClient) StartLongLivedLock(key string, owner string, renewInterval time.Duration, onLockOwnerChange func(newLockOwner string)) (lock *LiveLock) {
// Default to lock_manager.RenewInterval if zero duration is passed
if renewInterval == 0 {
renewInterval = lock_manager.RenewInterval
}
func (lc *LockClient) StartLongLivedLock(key string, owner string, onLockOwnerChange func(newLockOwner string), renewInterval time.Duration) (lock *LiveLock) {
lock = &LiveLock{
key: key,
hostFiler: lc.seedFiler,
@@ -76,6 +72,9 @@ func (lc *LockClient) StartLongLivedLock(key string, owner string, renewInterval
lc: lc,
renewInterval: renewInterval,
}
if lock.renewInterval == 0 {
lock.renewInterval = lock_manager.RenewInterval
}
go func() {
isLocked := false
lockOwner := ""
+2 -2
View File
@@ -140,10 +140,10 @@ func NewMessageBroker(option *MessageQueueBrokerOption, grpcDialOption grpc.Dial
newBrokerBalancerCh := make(chan string, 1)
lockClient := cluster.NewLockClient(grpcDialOption, mqBroker.currentFiler)
mqBroker.lockAsBalancer = lockClient.StartLongLivedLock(pub_balancer.LockBrokerBalancer, string(self), lock_manager.RenewInterval, func(newLockOwner string) {
mqBroker.lockAsBalancer = lockClient.StartLongLivedLock(pub_balancer.LockBrokerBalancer, string(self), func(newLockOwner string) {
glog.V(0).Infof("broker %s found balanacer %s", self, newLockOwner)
newBrokerBalancerCh <- newLockOwner
})
}, lock_manager.RenewInterval)
mqBroker.KeepConnectedToBrokerBalancer(newBrokerBalancerCh)
}()
@@ -180,8 +180,8 @@ func (cr *CoordinatorRegistry) startLeaderElection() {
cr.leaderLock = cr.lockClient.StartLongLivedLock(
GatewayLeaderLockKey,
cr.gatewayAddress,
lock_manager.RenewInterval,
cr.onLeadershipChange,
lock_manager.RenewInterval,
)
// Wait for shutdown
+2 -2
View File
@@ -60,9 +60,9 @@ func (s3a *S3ApiServer) startBucketSizeMetricsLoop(ctx context.Context) {
owner := string(filer) + "-s3-metrics"
// Start long-lived lock - this S3 instance will only collect metrics when it holds the lock
lock := lockClient.StartLongLivedLock(s3MetricsLockName, owner, lock_manager.RenewInterval, func(newLockOwner string) {
lock := lockClient.StartLongLivedLock(s3MetricsLockName, owner, func(newLockOwner string) {
glog.V(1).Infof("S3 bucket size metrics lock owner changed to: %s", newLockOwner)
})
}, lock_manager.RenewInterval)
defer lock.Stop()
ticker := time.NewTicker(bucketSizeMetricsInterval)