You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "nagisa-kunhah (via GitHub)" <gi...@apache.org> on 2026/03/27 19:56:39 UTC

[PR] Fix/3246 url memory leaks [dubbo-go]

nagisa-kunhah opened a new pull request, #3282:
URL: https://github.com/apache/dubbo-go/pull/3282

   ### Description
   Fixes #3246
   
   ### Checklist
   - [ ] I confirm the target branch is `develop`
   - [ ] Code has passed local testing
   - [ ] I have added tests that prove my fix is effective or that my feature works
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "AlexStocks (via GitHub)" <gi...@apache.org>.
AlexStocks commented on code in PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#discussion_r3041495932


##########
registry/directory/directory.go:
##########
@@ -271,34 +271,49 @@ func (dir *RegistryDirectory) refreshInvokers(event *registry.ServiceEvent) {
 // not in the incoming list can be removed.  The Action of serviceEvent should be EventTypeUpdate or EventTypeAdd.
 func (dir *RegistryDirectory) refreshAllInvokers(events []*registry.ServiceEvent, callback func()) {
 	var (
-		oldInvokers []protocolbase.Invoker
-		addEvents   []*registry.ServiceEvent
+		oldInvokers      []protocolbase.Invoker
+		addEvents        []*registry.ServiceEvent
+		providerEvents   []*registry.ServiceEvent
+		configuratorURLs []*common.URL
 	)
-	dir.overrideUrl(dir.GetDirectoryUrl())
-	referenceUrl := dir.GetDirectoryUrl().SubURL
-
-	// loop the events to check the Action should be EventTypeUpdate.
 	for _, event := range events {
 		if event.Action != remoting.EventTypeUpdate && event.Action != remoting.EventTypeAdd {
 			panic("Your implements of register center is wrong, " +
 				"please check the Action of ServiceEvent should be EventTypeUpdate")
 		}
+		if isConfiguratorURL(event.Service) {
+			configuratorURLs = append(configuratorURLs, event.Service)
+			continue
+		}
+		providerEvents = append(providerEvents, event)
+	}
+	if configuratorURLs != nil {
+		dir.replaceConfigurators(configuratorURLs)
+	}
+	defer callback()
+	if len(providerEvents) == 0 && len(events) > 0 {
+		return

Review Comment:
   [P1] 这里在 configurator-only 的 `NotifyAll` 场景下直接 `return`,只替换了 `dir.configurators`,但没有把新规则重新应用到已经缓存的 invoker。结果就是这批 override 要等下一次 provider 事件或配置中心事件触发后才会真正生效,Alan 之前提的那个语义问题还在。建议这里要么遍历 `cacheInvokersMap` 按原始 provider URL 重新 `overrideUrl + doCacheInvoker`,要么至少补一个覆盖现有 cached invoker 立即刷新行为的测试,确保纯 configurator 批次不会静默延迟。



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "nagisa-kunhah (via GitHub)" <gi...@apache.org>.
nagisa-kunhah commented on code in PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#discussion_r3004529368


##########
common/url.go:
##########
@@ -102,6 +96,7 @@ type URL struct {
 	Port     string
 
 	PrimitiveURL string
+	primitiveTS  string

Review Comment:
   primitiveTS just caches the original timestamp from c.PrimitiveURL. Previously, GetCacheInvokerMapKey() reparsed PrimitiveURL and used that value, not the current mutable params. This keeps the same behavior and only removes the extra allocation.
   https://github.com/apache/dubbo-go/blob/fb8eff2f090851261e2d1acfc55414ede91ca9c0/common/url.go#L418-L428



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "nagisa-kunhah (via GitHub)" <gi...@apache.org>.
nagisa-kunhah commented on code in PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#discussion_r3039999176


##########
common/url.go:
##########
@@ -102,6 +102,7 @@ type URL struct {
 	Port     string
 
 	PrimitiveURL string
+	primitiveTS  string

Review Comment:
   fix it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl commented on code in PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#discussion_r3108282510


##########
registry/directory/directory.go:
##########
@@ -250,34 +250,49 @@ func (dir *RegistryDirectory) refreshInvokers(event *registry.ServiceEvent) {
 // not in the incoming list can be removed.  The Action of serviceEvent should be EventTypeUpdate or EventTypeAdd.
 func (dir *RegistryDirectory) refreshAllInvokers(events []*registry.ServiceEvent, callback func()) {

Review Comment:
   For `NotifyAll`, I think we should treat the incoming configurator set as the authoritative current snapshot.
   
   So for a configurator-only `NotifyAll`, my expectation is:
   - rebuild from the original provider URL
   - then apply the current configurator snapshot
   - not re-apply on top of the current effective invoker URL
   
   Otherwise rules that disappeared from the latest snapshot would keep leaking into the effective URL, which makes `replace-by-batch` non-idempotent.
   
   So in your example, I would expect the first behavior, not the layered one.
   
   That said, I think this is separate from the original review point: even if we choose snapshot semantics, a configurator-only `NotifyAll` should still recompute the existing cached invokers immediately. Returning early after `replaceConfigurators(...)` means the new snapshot does not take effect until the next provider event, which seems incorrect for `NotifyAll`.
   
   A test that starts with cached provider invokers, sends a configurator-only `NotifyAll`, and verifies the invokers are rebuilt from the original provider URLs against the new configurator snapshot would probably make the intended behavior explicit.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl merged PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#issuecomment-4147669695

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3282) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [5 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3282&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3282&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=3282&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3282&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3282&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3282)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl commented on code in PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#discussion_r3005705930


##########
registry/directory/directory.go:
##########
@@ -250,34 +250,49 @@ func (dir *RegistryDirectory) refreshInvokers(event *registry.ServiceEvent) {
 // not in the incoming list can be removed.  The Action of serviceEvent should be EventTypeUpdate or EventTypeAdd.
 func (dir *RegistryDirectory) refreshAllInvokers(events []*registry.ServiceEvent, callback func()) {

Review Comment:
   In `refreshAllInvokers`, a batch containing only configurator URLs now returns early after `replaceConfigurators(...)`. This updates `dir.configurators`, but seems to skip rebuilding/reapplying overrides to the existing cached invokers.
   Could this delay configurator-only updates until the next provider event? It may be worth adding a test that starts with cached provider invokers, sends a configurator-only `NotifyAll`, and verifies the effective invoker URLs are refreshed immediately.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#issuecomment-4320061444

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3282) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3282&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3282&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=3282&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3282&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [10.9% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3282&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3282)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl commented on PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#issuecomment-4149428133

   > here are some confusement about this issue
   > 
   > 1. For P1–5, my understanding is that the original behavior may have been to append the new config and apply it together with the existing one. However, based on BaseConfigurationListener.Process, it seems the behavior there is to replace the existing config entirely. Which behavior is actually expected here?
   > 2. For P2-2, the original behavior in isMatched is to append. Replacing it with SetParam may change that behavior. Is that expected?
   >    @Alanxtl @AlexStocks
   
   as for 2, do you mean P2-3? 
   If the goal is only to avoid duplicate growth while preserving append semantics, another option would be to append only when configurators is not already present.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#issuecomment-4144920211

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3282) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [5 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3282&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3282&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=3282&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3282&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3282&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3282)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "AlexStocks (via GitHub)" <gi...@apache.org>.
AlexStocks commented on PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#issuecomment-4192095727

   please fix the file confliction.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "nagisa-kunhah (via GitHub)" <gi...@apache.org>.
nagisa-kunhah commented on PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#issuecomment-4147713736

   here are some confusement about this issue
   1. For P1–5, my understanding is that the original behavior may have been to append the new config and apply it together with the existing one. However, based on BaseConfigurationListener.Process, it seems the behavior there is to replace the existing config entirely. Which behavior is actually expected here?
   2. For P2-2, the original behavior in isMatched is to append. Replacing it with SetParam may change that behavior. Is that expected?
   @Alanxtl @AlexStocks 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "No-SilverBullet (via GitHub)" <gi...@apache.org>.
No-SilverBullet commented on code in PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#discussion_r3014561563


##########
common/url.go:
##########
@@ -102,6 +102,7 @@ type URL struct {
 	Port     string
 
 	PrimitiveURL string
+	primitiveTS  string

Review Comment:
   Add a comment here, "primitiveTS caches......"



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#issuecomment-4320024549

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3282) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3282&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3282&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=3282&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3282&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [6.1% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3282&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3282)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "AlexStocks (via GitHub)" <gi...@apache.org>.
AlexStocks commented on PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#issuecomment-4181590480

   文件都冲突了
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#issuecomment-4192353598

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3282) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [5 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3282&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3282&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=3282&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3282&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3282&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3282)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "nagisa-kunhah (via GitHub)" <gi...@apache.org>.
nagisa-kunhah commented on code in PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#discussion_r3106766884


##########
registry/directory/directory.go:
##########
@@ -250,34 +250,49 @@ func (dir *RegistryDirectory) refreshInvokers(event *registry.ServiceEvent) {
 // not in the incoming list can be removed.  The Action of serviceEvent should be EventTypeUpdate or EventTypeAdd.
 func (dir *RegistryDirectory) refreshAllInvokers(events []*registry.ServiceEvent, callback func()) {

Review Comment:
   @Alanxtl Hi, could you please take a look at my question above when you have a chance? Thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl commented on PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#issuecomment-4272538225

   pls fix conflict


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "nagisa-kunhah (via GitHub)" <gi...@apache.org>.
nagisa-kunhah commented on code in PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#discussion_r3004515280


##########
common/url.go:
##########
@@ -596,6 +590,20 @@ func (c *URL) GetAttribute(key string) (any, bool) {
 	return r, ok
 }
 
+func (c *URL) DeleteAttribute(key string) {
+	c.attributesLock.Lock()
+	defer c.attributesLock.Unlock()
+	if c.attributes != nil {
+		delete(c.attributes, key)
+	}
+}
+
+func (c *URL) ClearAttributes() {
+	c.attributesLock.Lock()
+	defer c.attributesLock.Unlock()
+	c.attributes = nil

Review Comment:
   ok, fix it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "nagisa-kunhah (via GitHub)" <gi...@apache.org>.
nagisa-kunhah commented on code in PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#discussion_r3156769123


##########
registry/protocol/protocol.go:
##########
@@ -275,6 +275,13 @@ func (proto *registryProtocol) reExport(invoker base.Invoker, newUrl *common.URL
 		wrappedNewInvoker := newInvokerDelegate(invoker, newUrl)
 		oldExporter.(base.Exporter).UnExport()
 		proto.bounds.Delete(key)
+
+		oldProviderURL := getProviderUrl(invoker)
+		oldOverrideURL := getSubscribedOverrideUrl(oldProviderURL)
+		oldOverrideKey := oldOverrideURL.String()
+		proto.overrideListeners.Delete(oldOverrideKey)
+		proto.serviceConfigurationListeners.Delete(oldProviderURL.ServiceKey())
+
 		// oldExporter UnExport function unRegister rpcService from the serviceMap, so need register it again as far as possible
 		if err := registerServiceMap(invoker); err != nil {
 			logger.Error(err.Error())

Review Comment:
   ok, I fix it by unsubsribe the listener in reExport and Destroy.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "nagisa-kunhah (via GitHub)" <gi...@apache.org>.
nagisa-kunhah commented on code in PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#discussion_r3156779145


##########
common/url.go:
##########
@@ -653,9 +667,29 @@ func (c *URL) GetNonDefaultParam(s string) (string, bool) {
 	return r, r != ""
 }
 
-// GetParams gets values
+// GetParams gets values.
+// Deprecated: use CopyParams instead.
 func (c *URL) GetParams() url.Values {
-	return c.params
+	return c.CopyParams()
+}
+
+// CopyParams returns a deep copy of params.
+func (c *URL) CopyParams() url.Values {
+	c.paramsLock.RLock()
+	defer c.paramsLock.RUnlock()
+
+	if c.params == nil {
+		return nil
+	}
+
+	params := make(url.Values, len(c.params))
+	for k, vs := range c.params {
+		copied := make([]string, len(vs))
+		copy(copied, vs)
+		params[k] = copied
+	}
+
+	return params
 }

Review Comment:
   ok, updated ToConfigurators to clone the URL, remove anyhost from the clone, and build the configurator from that filtered URL



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#issuecomment-4338856800

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3282) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3282&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3282&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=3282&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3282&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [8.5% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3282&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3282)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl commented on PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#issuecomment-4146443550

   our project use `import-formatter` to format import blocks, that's the reason why ur CI fails. For you, u should 
   
   1. run `go install github.com/dubbogo/tools/cmd/imports-formatter@latest`
   2. cd to the root dir of `dubbo-go`
   3. run `imports-formatter`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "nagisa-kunhah (via GitHub)" <gi...@apache.org>.
nagisa-kunhah commented on code in PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#discussion_r3004545811


##########
common/url.go:
##########
@@ -653,9 +661,29 @@ func (c *URL) GetNonDefaultParam(s string) (string, bool) {
 	return r, r != ""
 }
 
-// GetParams gets values
+// GetParams gets values.
+// Deprecated: use CopyParams instead.
 func (c *URL) GetParams() url.Values {
-	return c.params
+	return c.CopyParams()
+}
+
+// CopyParams returns a deep copy of params.
+func (c *URL) CopyParams() url.Values {
+	c.paramsLock.RLock()
+	defer c.paramsLock.RUnlock()
+
+	if c.params == nil {
+		return nil
+	}
+
+	params := make(url.Values, len(c.params))
+	for k, vs := range c.params {
+		copied := make([]string, len(vs))
+		copy(copied, vs)
+		params[k] = copied
+	}
+
+	return params
 }
 

Review Comment:
   Since the issue points out that callers may retain the internal params map and mutate it without locking, returning it directly is unsafe. So GetParams() now returns a copy; if a caller only needs a single value, it should use GetParam() instead.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "nagisa-kunhah (via GitHub)" <gi...@apache.org>.
nagisa-kunhah commented on code in PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#discussion_r3040086059


##########
registry/directory/directory.go:
##########
@@ -250,34 +250,49 @@ func (dir *RegistryDirectory) refreshInvokers(event *registry.ServiceEvent) {
 // not in the incoming list can be removed.  The Action of serviceEvent should be EventTypeUpdate or EventTypeAdd.
 func (dir *RegistryDirectory) refreshAllInvokers(events []*registry.ServiceEvent, callback func()) {

Review Comment:
   I think there are two possible behaviors for configurator-only `NotifyAll`, and I’d like to confirm which one we want before changing the rebuild logic.
   
   Example:
   
   - original provider URL:
     `dubbo://10.0.0.8:20880/com.foo.UserService?group=g1&version=1.0.0&serialization=fastjson&warmup=100`
   - consumer reference URL:
     `dubbo://127.0.0.1/com.foo.UserService?group=g1&version=1.0.0&timeout=3000&cluster=failover`
   
   Then suppose we receive one configurator-only batch:
   
   - first batch:
     `override://0.0.0.0/com.foo.UserService?timeout=2s&serialization=hessian2`
   
   and later another configurator-only batch:
   
   - next batch:
     `override://0.0.0.0/com.foo.UserService?cluster=mock3`
   
   If we rebuild from the original provider URL each time, the final effective URL would become:
   
   `dubbo://10.0.0.8:20880/com.foo.UserService?group=g1&version=1.0.0&serialization=fastjson&warmup=100&timeout=3000&cluster=mock3`
   
   If we instead re-apply the new configurator batch on top of the current effective invoker URL, the final URL would become:
   
   `dubbo://10.0.0.8:20880/com.foo.UserService?group=g1&version=1.0.0&serialization=hessian2&warmup=100&timeout=2s&cluster=mock3`
   
   Since this patch changed configurator handling from append to replace-by-batch, I’m leaning toward the first behavior, but I’d like to confirm the expected semantics first.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#issuecomment-4338546021

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3282) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3282&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3282&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=3282&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3282&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [8.5% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3282&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3282)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "nagisa-kunhah (via GitHub)" <gi...@apache.org>.
nagisa-kunhah commented on PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#issuecomment-4192194823

   > please fix the file confliction.
   
   Thanks for the reminder. I’ve been a bit busy these past few days, and I’ll resolve the file conflict shortly.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#issuecomment-4147629046

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3282) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [5 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3282&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3282&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=3282&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3282&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3282&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3282)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl commented on code in PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#discussion_r3108293264


##########
registry/directory/directory.go:
##########
@@ -372,7 +387,13 @@ func (dir *RegistryDirectory) cacheInvokerByEvent(event *registry.ServiceEvent)
 
 		switch event.Action {
 		case remoting.EventTypeAdd, remoting.EventTypeUpdate:
+			if isConfiguratorURL(event.Service) {
+				dir.replaceConfigurators([]*common.URL{event.Service})
+			}
 			u := dir.convertUrl(event)
+			if u == nil && dir.cacheOriginUrl == nil {
+				return nil, nil
+			}
 			logger.Infof("[Registry Directory] selector add service url{%s}", event.Service)
 			if u != nil && constant.RouterProtocol == u.Protocol {
 				dir.configRouters()

Review Comment:
   The single-event path now replaces `dir.configurators` with a slice containing only the latest configurator URL. If the registry sends override rules as incremental add/update events, each new rule wipes out the previously active ones, so only the last configurator remains effective. This breaks multi-rule override scenarios even though the new tests do not cover them.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl commented on code in PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#discussion_r3143185383


##########
common/url.go:
##########
@@ -653,9 +667,29 @@ func (c *URL) GetNonDefaultParam(s string) (string, bool) {
 	return r, r != ""
 }
 
-// GetParams gets values
+// GetParams gets values.
+// Deprecated: use CopyParams instead.
 func (c *URL) GetParams() url.Values {
-	return c.params
+	return c.CopyParams()
+}
+
+// CopyParams returns a deep copy of params.
+func (c *URL) CopyParams() url.Values {
+	c.paramsLock.RLock()
+	defer c.paramsLock.RUnlock()
+
+	if c.params == nil {
+		return nil
+	}
+
+	params := make(url.Values, len(c.params))
+	for k, vs := range c.params {
+		copied := make([]string, len(vs))
+		copy(copied, vs)
+		params[k] = copied
+	}
+
+	return params
 }

Review Comment:
   This PR changes `GetParams()` to return a deep copy, but `ToConfigurators` still does `override := url.GetParams()`; `delete(override, constant.AnyhostKey)`. That delete no longer mutates the configurator URL. For override URLs containing anyhost plus real config params, anyhost will now remain on the configurator URL and can be written into provider/consumer URLs when Configure calls CloneExceptParams(...).SetParams(...). 
   
   What about update `ToConfigurators` to clone/filter the URL explicitly before building the configurator?



##########
registry/protocol/protocol.go:
##########
@@ -275,6 +275,13 @@ func (proto *registryProtocol) reExport(invoker base.Invoker, newUrl *common.URL
 		wrappedNewInvoker := newInvokerDelegate(invoker, newUrl)
 		oldExporter.(base.Exporter).UnExport()
 		proto.bounds.Delete(key)
+
+		oldProviderURL := getProviderUrl(invoker)
+		oldOverrideURL := getSubscribedOverrideUrl(oldProviderURL)
+		oldOverrideKey := oldOverrideURL.String()
+		proto.overrideListeners.Delete(oldOverrideKey)
+		proto.serviceConfigurationListeners.Delete(oldProviderURL.ServiceKey())
+
 		// oldExporter UnExport function unRegister rpcService from the serviceMap, so need register it again as far as possible
 		if err := registerServiceMap(invoker); err != nil {
 			logger.Error(err.Error())

Review Comment:
   `reExport` removes the old override/service listeners from local `sync.Maps`, but the old listener was already passed to `reg.Subscribe` and remains owned by the registry subscription goroutine. That means the listener and its captured invoker/protocol can still be retained, so the memory leak is only partially fixed; stale override events may also continue to hit the old listener. The old listener should be loaded before deletion and passed to `reg.UnSubscribe`(oldOverrideURL, oldListener) where the registry supports it; Destroy has the same cleanup gap for exporter.subscribeUrl.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "nagisa-kunhah (via GitHub)" <gi...@apache.org>.
nagisa-kunhah commented on code in PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#discussion_r3156769123


##########
registry/protocol/protocol.go:
##########
@@ -275,6 +275,13 @@ func (proto *registryProtocol) reExport(invoker base.Invoker, newUrl *common.URL
 		wrappedNewInvoker := newInvokerDelegate(invoker, newUrl)
 		oldExporter.(base.Exporter).UnExport()
 		proto.bounds.Delete(key)
+
+		oldProviderURL := getProviderUrl(invoker)
+		oldOverrideURL := getSubscribedOverrideUrl(oldProviderURL)
+		oldOverrideKey := oldOverrideURL.String()
+		proto.overrideListeners.Delete(oldOverrideKey)
+		proto.serviceConfigurationListeners.Delete(oldProviderURL.ServiceKey())
+
 		// oldExporter UnExport function unRegister rpcService from the serviceMap, so need register it again as far as possible
 		if err := registerServiceMap(invoker); err != nil {
 			logger.Error(err.Error())

Review Comment:
   ok, fixed by unsubscribing the old override listener during reExport and cleaning up the subscribed override listener during Destroy.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl commented on PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#issuecomment-4188941218

   pls resolve file confilct


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl commented on code in PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#discussion_r3004005975


##########
common/url.go:
##########
@@ -102,6 +96,7 @@ type URL struct {
 	Port     string
 
 	PrimitiveURL string
+	primitiveTS  string

Review Comment:
   what does TS stand for?



##########
common/url.go:
##########
@@ -653,9 +661,29 @@ func (c *URL) GetNonDefaultParam(s string) (string, bool) {
 	return r, r != ""
 }
 
-// GetParams gets values
+// GetParams gets values.
+// Deprecated: use CopyParams instead.
 func (c *URL) GetParams() url.Values {
-	return c.params
+	return c.CopyParams()
+}
+
+// CopyParams returns a deep copy of params.
+func (c *URL) CopyParams() url.Values {
+	c.paramsLock.RLock()
+	defer c.paramsLock.RUnlock()
+
+	if c.params == nil {
+		return nil
+	}
+
+	params := make(url.Values, len(c.params))
+	for k, vs := range c.params {
+		copied := make([]string, len(vs))
+		copy(copied, vs)
+		params[k] = copied
+	}
+
+	return params
 }
 

Review Comment:
   every time I want to `GetParams()`, CopyParams() will generate a new map, it is consuming



##########
common/url.go:
##########
@@ -596,6 +590,20 @@ func (c *URL) GetAttribute(key string) (any, bool) {
 	return r, ok
 }
 
+func (c *URL) DeleteAttribute(key string) {
+	c.attributesLock.Lock()
+	defer c.attributesLock.Unlock()
+	if c.attributes != nil {
+		delete(c.attributes, key)
+	}
+}
+
+func (c *URL) ClearAttributes() {
+	c.attributesLock.Lock()
+	defer c.attributesLock.Unlock()
+	c.attributes = nil

Review Comment:
   isn't it better to set `c.attributes` into a empty map instead of `nil` ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#issuecomment-4147606851

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3282) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [5 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3282&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3282&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=3282&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3282&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3282&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3282)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#issuecomment-4147676952

   ## [Codecov](https://app.codecov.io/gh/apache/dubbo-go/pull/3282?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `85.39326%` with `13 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 49.07%. Comparing base ([`fb8eff2`](https://app.codecov.io/gh/apache/dubbo-go/commit/fb8eff2f090851261e2d1acfc55414ede91ca9c0?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`7de710d`](https://app.codecov.io/gh/apache/dubbo-go/commit/7de710d49a47e8ea9364efbb9bdb5926324c02df?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/dubbo-go/pull/3282?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [registry/mock\_registry.go](https://app.codecov.io/gh/apache/dubbo-go/pull/3282?src=pr&el=tree&filepath=registry%2Fmock_registry.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cmVnaXN0cnkvbW9ja19yZWdpc3RyeS5nbw==) | 0.00% | [9 Missing :warning: ](https://app.codecov.io/gh/apache/dubbo-go/pull/3282?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [common/url.go](https://app.codecov.io/gh/apache/dubbo-go/pull/3282?src=pr&el=tree&filepath=common%2Furl.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29tbW9uL3VybC5nbw==) | 92.59% | [1 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/dubbo-go/pull/3282?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [registry/protocol/protocol.go](https://app.codecov.io/gh/apache/dubbo-go/pull/3282?src=pr&el=tree&filepath=registry%2Fprotocol%2Fprotocol.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cmVnaXN0cnkvcHJvdG9jb2wvcHJvdG9jb2wuZ28=) | 88.23% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/dubbo-go/pull/3282?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff             @@
   ##           develop    #3282      +/-   ##
   ===========================================
   + Coverage    48.96%   49.07%   +0.10%     
   ===========================================
     Files          467      467              
     Lines        34006    34075      +69     
   ===========================================
   + Hits         16652    16722      +70     
   + Misses       16019    16016       -3     
   - Partials      1335     1337       +2     
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/dubbo-go/pull/3282?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Fix/3246 url memory leaks [dubbo-go]

Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl commented on code in PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#discussion_r3005702769


##########
common/url.go:
##########
@@ -653,9 +661,29 @@ func (c *URL) GetNonDefaultParam(s string) (string, bool) {
 	return r, r != ""
 }
 
-// GetParams gets values
+// GetParams gets values.
+// Deprecated: use CopyParams instead.
 func (c *URL) GetParams() url.Values {
-	return c.params
+	return c.CopyParams()
+}
+
+// CopyParams returns a deep copy of params.
+func (c *URL) CopyParams() url.Values {
+	c.paramsLock.RLock()
+	defer c.paramsLock.RUnlock()
+
+	if c.params == nil {
+		return nil
+	}
+
+	params := make(url.Values, len(c.params))
+	for k, vs := range c.params {
+		copied := make([]string, len(vs))
+		copy(copied, vs)
+		params[k] = copied
+	}
+
+	return params
 }
 

Review Comment:
   cool



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org