Skip to content

Commit

Permalink
Use trylock for populating parents/children in catalog queries (#2747)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaHegde committed Jul 7, 2023
1 parent 3d105ab commit 2bca601
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions runtime/services/catalog/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ func (s *Service) FindEntries(ctx context.Context, typ drivers.ObjectType) ([]*d
if err != nil {
return nil, err
}
s.Meta.lock.RLock()
defer s.Meta.lock.RUnlock()
for _, entry := range entries {
s.Meta.fillDAGInEntry(entry)
if s.Meta.lock.TryRLock() {
defer s.Meta.lock.RUnlock()

for _, entry := range entries {
s.Meta.fillDAGInEntry(entry)
}
}
return entries, nil
}
Expand All @@ -65,9 +67,11 @@ func (s *Service) FindEntry(ctx context.Context, name string) (*drivers.CatalogE
if err != nil {
return nil, err
}
s.Meta.lock.RLock()
defer s.Meta.lock.RUnlock()
s.Meta.fillDAGInEntry(entry)
if s.Meta.lock.TryRLock() {
defer s.Meta.lock.RUnlock()

s.Meta.fillDAGInEntry(entry)
}
return entry, nil
}

Expand Down

0 comments on commit 2bca601

Please sign in to comment.