Skip to content

Commit ea3bcce

Browse files
authored
Revert mutex changes db openRepository (#374)
1 parent 4e50a2a commit ea3bcce

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

pkg/cache/dbcache/dbcache.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ func (c *dbCache) OpenRepository(ctx context.Context, repositorySpec *configapi.
5252
return nil, err
5353
}
5454

55-
c.mainLock.Lock()
56-
defer c.mainLock.Unlock()
55+
c.mainLock.RLock()
5756

5857
if dbRepo, ok := c.repositories[repoKey]; ok {
58+
c.mainLock.RUnlock()
5959
// Keep the spec updated in the cache.
6060
dbRepo.spec = repositorySpec
6161
err := externalrepo.CheckRepositoryConnection(ctx, dbRepo.spec, c.options.ExternalRepoOptions)
@@ -66,6 +66,7 @@ func (c *dbCache) OpenRepository(ctx context.Context, repositorySpec *configapi.
6666
klog.V(2).Infof("dbCache::OpenRepository: verified repo connectivity %+v", repoKey)
6767
return dbRepo, nil
6868
}
69+
c.mainLock.RUnlock()
6970

7071
dbRepo := &dbRepository{
7172
repoKey: repoKey,
@@ -82,7 +83,9 @@ func (c *dbCache) OpenRepository(ctx context.Context, repositorySpec *configapi.
8283
return nil, err
8384
}
8485

86+
c.mainLock.Lock()
8587
c.repositories[repoKey] = dbRepo
88+
c.mainLock.Unlock()
8689

8790
dbRepo.repositorySync = newRepositorySync(dbRepo, c.options)
8891

pkg/externalrepo/git/git.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ type gitRepository struct {
267267
// through all the refs each time
268268
deletionProposedCache map[BranchName]bool
269269

270-
mutex sync.RWMutex
270+
mutex sync.Mutex
271271

272272
// caBundle to use for TLS communication towards git
273273
caBundle []byte

0 commit comments

Comments
 (0)