From 74ab35767f1628710176f3cfefa4a9059095ce21 Mon Sep 17 00:00:00 2001 From: Gustaf Lindstedt Date: Mon, 12 Jun 2023 16:09:59 +0200 Subject: [PATCH] Unlock redsync locks using context.Background() If using the same context that was passed in from the original call, there's a risk that the context has been canceled. This would cause the Unlock operation to fail and leave the lock in a locked state. --- internal/app/backend/backend_service.go | 2 +- internal/app/frontend/frontend_service.go | 4 ++-- internal/statestore/backfill.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/app/backend/backend_service.go b/internal/app/backend/backend_service.go index e211acffe..e4e76839e 100644 --- a/internal/app/backend/backend_service.go +++ b/internal/app/backend/backend_service.go @@ -388,7 +388,7 @@ func createOrUpdateBackfill(ctx context.Context, backfill *pb.Backfill, ticketId } defer func() { - _, unlockErr := m.Unlock(ctx) + _, unlockErr := m.Unlock(context.Background()) if unlockErr != nil { logger.WithFields(logrus.Fields{"backfill_id": backfill.Id}).WithError(unlockErr).Error("failed to make unlock") } diff --git a/internal/app/frontend/frontend_service.go b/internal/app/frontend/frontend_service.go index 45fe95753..3707cb7b7 100644 --- a/internal/app/frontend/frontend_service.go +++ b/internal/app/frontend/frontend_service.go @@ -171,7 +171,7 @@ func (s *frontendService) UpdateBackfill(ctx context.Context, req *pb.UpdateBack return nil, err } defer func() { - if _, err = m.Unlock(ctx); err != nil { + if _, err = m.Unlock(context.Background()); err != nil { logger.WithError(err).Error("error on mutex unlock") } }() @@ -332,7 +332,7 @@ func (s *frontendService) AcknowledgeBackfill(ctx context.Context, req *pb.Ackno return nil, err } defer func() { - if _, err = m.Unlock(ctx); err != nil { + if _, err = m.Unlock(context.Background()); err != nil { logger.WithError(err).Error("error on mutex unlock") } }() diff --git a/internal/statestore/backfill.go b/internal/statestore/backfill.go index 02ae68926..62a6f2705 100644 --- a/internal/statestore/backfill.go +++ b/internal/statestore/backfill.go @@ -242,7 +242,7 @@ func (rb *redisBackend) DeleteBackfillCompletely(ctx context.Context, id string) } defer func() { - if _, err = m.Unlock(ctx); err != nil { + if _, err = m.Unlock(context.Background()); err != nil { logger.WithError(err).Error("error on mutex unlock") } }()