Skip to content

Commit f9d2ee9

Browse files
authored
fix(repositories): remove Lock Access in unlockfunc (#6295)
1 parent 153be18 commit f9d2ee9

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

engine/repositories/cleaner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (s *Service) vacuumFileSystemCleanerFunc(ctx context.Context, repoUUID stri
8787

8888
if !s.dao.isExpired(ctx, repoUUID) {
8989
log.Debug(ctx, "vacuumFileSystemCleanerFunc> %s is not expired. skipping", repoUUID)
90-
_ = s.dao.unlock(ctx, repoUUID, 24*time.Hour*time.Duration(s.Cfg.RepositoriesRetention))
90+
_ = s.dao.unlock(ctx, repoUUID)
9191
return nil
9292
}
9393

engine/repositories/dao.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,10 @@ func (d *dao) deleteLock(ctx context.Context, uuid string) error {
8080
return nil
8181
}
8282

83-
func (d *dao) unlock(ctx context.Context, uuid string, retention time.Duration) error {
83+
func (d *dao) unlock(ctx context.Context, uuid string) error {
8484
if err := d.store.Unlock(cache.Key(locksKey, uuid)); err != nil {
8585
log.Error(ctx, "error on unlock uuid %s: %v", uuid, err)
8686
}
87-
if _, err := d.store.Lock(cache.Key(lastAccessKey, uuid), retention, -1, -1); err != nil {
88-
return sdk.WrapError(err, "error on cache.lock uuid:%s", uuid)
89-
}
9087
return nil
9188
}
9289

engine/repositories/processor.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import (
44
"context"
55
"time"
66

7+
"github.com/rockbears/log"
8+
9+
"github.com/ovh/cds/engine/cache"
710
"github.com/ovh/cds/sdk"
811
cdslog "github.com/ovh/cds/sdk/log"
9-
"github.com/rockbears/log"
1012
)
1113

1214
func (s *Service) processor(ctx context.Context) error {
@@ -51,7 +53,10 @@ func (s *Service) do(ctx context.Context, op sdk.Operation) error {
5153
if s.dao.lock(r.ID()) == errLockUnavailable {
5254
return errLockUnavailable
5355
}
54-
defer s.dao.unlock(ctx, r.ID(), 24*time.Hour*time.Duration(s.Cfg.RepositoriesRetention)) // nolint
56+
defer func() {
57+
s.dao.unlock(ctx, r.ID())
58+
s.dao.store.Lock(cache.Key(lastAccessKey, r.ID()), 24*time.Hour*time.Duration(s.Cfg.RepositoriesRetention), -1, -1)
59+
}()
5560

5661
switch {
5762
// Load workflow as code file

0 commit comments

Comments
 (0)