databroker/leaser: set timeout on ReleaseLease (#5208)

This commit is contained in:
Denis Mishin 2024-08-06 14:47:59 -04:00 committed by GitHub
parent 28a20dd153
commit e2251b2d57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -112,7 +112,9 @@ func (locker *Leaser) runOnce(ctx context.Context, resetBackoff func()) error {
func (locker *Leaser) withLease(ctx context.Context, leaseID string) error {
// always release the lock in case the parent context is canceled
defer func() {
_, _ = locker.handler.GetDataBrokerServiceClient().ReleaseLease(context.Background(), &ReleaseLeaseRequest{
ctx, cancel := context.WithTimeout(context.WithoutCancel(ctx), locker.ttl)
defer cancel()
_, _ = locker.handler.GetDataBrokerServiceClient().ReleaseLease(ctx, &ReleaseLeaseRequest{
Name: locker.leaseName,
Id: leaseID,
})