Skip to content

Commit

Permalink
fix: avoid acquiring lock on two mutexes at the same time to prevent …
Browse files Browse the repository at this point in the history
…deadlock (#13636) (#13649)

Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
Co-authored-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
  • Loading branch information
gcp-cherry-pick-bot[bot] and alexmt authored May 18, 2023
1 parent 4d63d27 commit 876ff30
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions controller/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,11 @@ func (c *liveStateCache) getSyncedCluster(server string) (clustercache.ClusterCa
func (c *liveStateCache) invalidate(cacheSettings cacheSettings) {
log.Info("invalidating live state cache")
c.lock.Lock()
defer c.lock.Unlock()

c.cacheSettings = cacheSettings
for _, clust := range c.clusters {
clusters := c.clusters
c.lock.Unlock()

for _, clust := range clusters {
clust.Invalidate(clustercache.SetSettings(cacheSettings.clusterSettings))
}
log.Info("live state cache invalidated")
Expand Down

0 comments on commit 876ff30

Please sign in to comment.