VanKhanhAnny opened a new issue, #1073: URL: https://github.com/apache/incubator-seata-go/issues/1073
### ✅ Verification Checklist - [x] 🔍 I have searched the [existing issues](https://github.com/apache/incubator-seata-go/issues) and confirmed this is not a duplicate - [x] 🛠️ I am willing to try to fix this bug myself. ### 🚀 Go Version 1.24.4 ### 📦 Seata-go Version master (local checkout), commit a93f0ae ### 💾 Operating System 🪟 Windows ### 📝 Bug Description This looks like a selector-dispatch bug in core seata-go. In `pkg/remoting/loadbalance/loadbalance.go`, `Select(...)` currently handles: - `RandomLoadBalance` - `XID` - `RoundRobinLoadBalance` However, it does not dispatch: - `ConsistentHashLoadBalance` - `LeastActiveLoadBalance` Those two strategies already have implementation files in the repository: - `pkg/remoting/loadbalance/consistent_hash_loadbalance.go` - `pkg/remoting/loadbalance/least_active_loadbalance.go` Based on direct code inspection, configuring `ConsistentHashLoadBalance` or `LeastActiveLoadBalance` appears to fall through to the default branch in `Select(...)`, which uses random load balancing instead. This report is not about the algorithms being missing. Related historical issues/PRs appear to have added those algorithms. The issue here is that the selector still does not route to them. ### 🔄 Steps to Reproduce 1. Open `pkg/remoting/loadbalance/loadbalance.go`. 2. Inspect the `Select(loadBalanceType string, sessions *sync.Map, xid string)` function. 3. Observe that the switch only has explicit branches for `RandomLoadBalance`, `XID`, and `RoundRobinLoadBalance`. 4. Compare that with the existing implementation files: - `pkg/remoting/loadbalance/consistent_hash_loadbalance.go` - `pkg/remoting/loadbalance/least_active_loadbalance.go` 5. From the current selector logic, a configured value of `ConsistentHashLoadBalance` or `LeastActiveLoadBalance` appears to fall through to the default branch and use random load balancing. Note: this reproduction is based on code inspection. I have not yet verified a full end-to-end runtime reproduction or observed runtime logs. ### ✅ Expected Behavior If `loadBalanceType` is set to `ConsistentHashLoadBalance`, `Select(...)` should dispatch to the consistent-hash implementation. If `loadBalanceType` is set to `LeastActiveLoadBalance`, `Select(...)` should dispatch to the least-active implementation. ### ❌ Actual Behavior Based on direct code inspection, `Select(...)` does not have branches for those two strategy names, so they appear to fall through to the default branch and use random load balancing instead. ### 💡 Possible Solution - Add explicit selector branches for `ConsistentHashLoadBalance` and `LeastActiveLoadBalance` in `pkg/remoting/loadbalance/loadbalance.go`. - Add a selector-level regression test that verifies each supported `loadBalanceType` routes to the intended implementation. -- 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]
