fix: only clear exclude node list after refresh shard leader cache (#43553)

issue: #43511

Signed-off-by: Wei Liu <wei.liu@zilliz.com>
This commit is contained in:
wei liu 2025-07-25 14:18:54 +08:00 committed by GitHub
parent 5cebc9f7f6
commit 369a811ae1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 3 deletions

View File

@ -144,7 +144,7 @@ func (lb *LBPolicyImpl) selectNode(ctx context.Context, balancer LBBalancer, wor
// if all available delegator has been excluded even after refresh shard leader cache
// we should clear excludeNodes and try to select node again instead of failing the request at selectNode
if len(shardLeaders) > 0 && len(shardLeaders) <= excludeNodes.Len() {
if !withCache && len(shardLeaders) > 0 && len(shardLeaders) <= excludeNodes.Len() {
allReplicaExcluded := true
for _, node := range shardLeaders {
if !excludeNodes.Contain(node.nodeID) {

View File

@ -663,8 +663,6 @@ func (s *LBPolicySuite) TestSelectNodeWithExcludeClearing() {
s.lbBalancer.ExpectedCalls = nil
s.lbBalancer.EXPECT().RegisterNodeInfo(mock.Anything)
// First attempt fails due to no candidates
s.lbBalancer.EXPECT().SelectNode(mock.Anything, mock.Anything, mock.Anything).Return(-1, merr.ErrNodeNotAvailable).Times(1)
// Second attempt succeeds after exclude nodes are cleared
s.lbBalancer.EXPECT().SelectNode(mock.Anything, mock.Anything, mock.Anything).Return(1, nil).Times(1)
// Setup mock to return only excluded nodes first, then same nodes for retry