Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport: 1.5.x [动态配置]修复config_flow递归加读锁导致的死锁问题 (#212) #215

Merged
merged 1 commit into from
Aug 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions pkg/flow/configuration/config_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ func (c *ConfigFileFlow) mainLoop(ctx context.Context) {
changedConfigFile.GetFileName())

newNotifiedVersion := changedConfigFile.GetVersion()
oldNotifiedVersion := c.getConfigFileNotifiedVersion(cacheKey)
oldNotifiedVersion := c.getConfigFileNotifiedVersion(cacheKey, true)

maxVersion := oldNotifiedVersion
if newNotifiedVersion > oldNotifiedVersion {
Expand Down Expand Up @@ -382,7 +382,7 @@ func (c *ConfigFileFlow) assembleWatchConfigFiles() []*configconnector.ConfigFil
Namespace: configFileMetadata.GetNamespace(),
FileGroup: configFileMetadata.GetFileGroup(),
FileName: configFileMetadata.GetFileName(),
Version: c.getConfigFileNotifiedVersion(cacheKey),
Version: c.getConfigFileNotifiedVersion(cacheKey, false),
})
}

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

func (c *ConfigFileFlow) getConfigFileNotifiedVersion(cacheKey string) uint64 {
c.fclock.RLock()
defer c.fclock.RUnlock()
func (c *ConfigFileFlow) getConfigFileNotifiedVersion(cacheKey string, locking bool) uint64 {
if locking {
c.fclock.RLock()
defer c.fclock.RUnlock()
}
version, ok := c.notifiedVersion[cacheKey]
if !ok {
version = initVersion
Expand Down
Loading