Skip to content

Commit d27bee2

Browse files
authored
fix:[动态配置]修复config_flow递归加读锁导致的死锁问题 (#212) (#215)
Signed-off-by: ArmstrongCN <[email protected]>
1 parent 1f7b1e7 commit d27bee2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pkg/flow/configuration/config_flow.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ func (c *ConfigFileFlow) mainLoop(ctx context.Context) {
336336
changedConfigFile.GetFileName())
337337

338338
newNotifiedVersion := changedConfigFile.GetVersion()
339-
oldNotifiedVersion := c.getConfigFileNotifiedVersion(cacheKey)
339+
oldNotifiedVersion := c.getConfigFileNotifiedVersion(cacheKey, true)
340340

341341
maxVersion := oldNotifiedVersion
342342
if newNotifiedVersion > oldNotifiedVersion {
@@ -382,7 +382,7 @@ func (c *ConfigFileFlow) assembleWatchConfigFiles() []*configconnector.ConfigFil
382382
Namespace: configFileMetadata.GetNamespace(),
383383
FileGroup: configFileMetadata.GetFileGroup(),
384384
FileName: configFileMetadata.GetFileName(),
385-
Version: c.getConfigFileNotifiedVersion(cacheKey),
385+
Version: c.getConfigFileNotifiedVersion(cacheKey, false),
386386
})
387387
}
388388

@@ -395,9 +395,11 @@ func (c *ConfigFileFlow) updateNotifiedVersion(cacheKey string, version uint64)
395395
c.notifiedVersion[cacheKey] = version
396396
}
397397

398-
func (c *ConfigFileFlow) getConfigFileNotifiedVersion(cacheKey string) uint64 {
399-
c.fclock.RLock()
400-
defer c.fclock.RUnlock()
398+
func (c *ConfigFileFlow) getConfigFileNotifiedVersion(cacheKey string, locking bool) uint64 {
399+
if locking {
400+
c.fclock.RLock()
401+
defer c.fclock.RUnlock()
402+
}
401403
version, ok := c.notifiedVersion[cacheKey]
402404
if !ok {
403405
version = initVersion

0 commit comments

Comments
 (0)