zbchi opened a new issue, #3181: URL: https://github.com/apache/dubbo-go/issues/3181
### ✅ 验证清单 - [x] 🔍 我已经搜索过 [现有 Issues](https://github.com/apache/dubbo-go/issues),确信这不是重复问题 ### 🚀 Go 版本 1.24.0 ### 📦 Dubbo-go 版本 v3.3.1 ### 🖥️ 服务端配置 _No response_ ### 💻 客户端配置 _No response_ ### 🌐 协议配置 Triple ### 📋 注册中心配置 _No response_ ### 💾 操作系统 🐧 Linux ### 📝 Bug 描述 流量未命中预期的服务实例 ### 🔄 重现步骤 server-dev: ```go polarisAddr := "127.0.0.1:8091" ins, err := dubbo.NewInstance( dubbo.WithName("myApp"), dubbo.WithRegistry( registry.WithPolaris(), registry.WithAddress(polarisAddr), registry.WithNamespace("dubbogo"), registry.WithRegisterInterface(), ), dubbo.WithProtocol( protocol.WithTriple(), protocol.WithPort(20000), ), ) server.WithParam("env", "dev"), ``` server-pre: ```go ... server.WithParam("env", "pre") ``` server-prod: ```go ... server.WithParam("env", "prod") ``` client: ```go uid := os.Getenv("uid") for i := 0; i < 5; i++ { time.Sleep(200 * time.Millisecond) req := &user.User{Name: "Alex001"} ctx := context.WithValue(context.Background(), constant.AttachmentKey, map[string]interface{}{ "uid": uid, }) resp, err := svc.GetUser(ctx, req) } ``` 配置路由规则: ``` uid=user-1 -> pre uid=user-2 -> dev 其他 -> prod ``` 同时运行三个服务实例,并分别对不同的uid进行路由测试 ### ✅ 预期行为 ``` uid=user-1 -> pre uid=user-2 -> dev 其他 -> prod ``` ### ❌ 实际行为 路由规则失效,打入默认服务实例: ``` #export uid=user-1 2026-01-24 19:41:12 INFO cmd/client.go:78 uid=user-1, response: Alex Stocks:{id:"A001" name:"[Prod] User" age:18 time:1769254872} 2026-01-24 19:41:12 INFO cmd/client.go:78 uid=user-1, response: Alex Stocks:{id:"A001" name:"[Prod] User" age:18 time:1769254872} #export uid=user-2 2026-01-24 19:43:08 INFO cmd/client.go:78 uid=user-2, response: Alex Stocks:{id:"A001" name:"[Prod] User" age:18 time:1769254988} 2026-01-24 19:43:08 INFO cmd/client.go:78 uid=user-2, response: Alex Stocks:{id:"A001" name:"[Prod] User" age:18 time:1769254988} ### 💡 可能的解决方案 从ctx读取attachements发生在路由选择之后 -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
