Skip to content

Commit

Permalink
fix: Make querycoord panick when rg metastore sync fail (#34106)
Browse files Browse the repository at this point in the history
See also #34047

When `unassignNode` sync resource group with node removed failed

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
  • Loading branch information
congqixia committed Jun 24, 2024
1 parent 68fe6f9 commit 07c25a1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
3 changes: 1 addition & 2 deletions internal/querycoordv2/meta/resource_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -820,12 +820,11 @@ func (rm *ResourceManager) unassignNode(node int64) (string, error) {
mrg.UnassignNode(node)
rg := mrg.ToResourceGroup()
if err := rm.catalog.SaveResourceGroup(rg.GetMeta()); err != nil {
log.Warn("unassign node from resource group",
log.Fatal("unassign node from resource group",
zap.String("rgName", rg.GetName()),
zap.Int64("node", node),
zap.Error(err),
)
return "", merr.WrapErrResourceGroupServiceAvailable()
}

// Commit updates to memory.
Expand Down
28 changes: 28 additions & 0 deletions internal/querycoordv2/meta/resource_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ package meta
import (
"testing"

"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/suite"

"github.com/milvus-io/milvus-proto/go-api/v2/rgpb"
"github.com/milvus-io/milvus/internal/kv"
etcdkv "github.com/milvus-io/milvus/internal/kv/etcd"
"github.com/milvus-io/milvus/internal/kv/mocks"
"github.com/milvus-io/milvus/internal/metastore/kv/querycoord"
"github.com/milvus-io/milvus/internal/querycoordv2/params"
"github.com/milvus-io/milvus/internal/querycoordv2/session"
Expand Down Expand Up @@ -591,3 +593,29 @@ func (suite *ResourceManagerSuite) TestIncomingNode() {
suite.NoError(err)
suite.Len(nodes, 1)
}

func (suite *ResourceManagerSuite) TestUnassignFail() {
// suite.man
mockKV := mocks.NewMetaKv(suite.T())
mockKV.EXPECT().MultiSave(mock.Anything).Return(nil).Once()

store := querycoord.NewCatalog(mockKV)
suite.manager = NewResourceManager(store, session.NewNodeManager())

suite.manager.UpdateResourceGroups(map[string]*rgpb.ResourceGroupConfig{
"rg1": newResourceGroupConfig(20, 30),
})

suite.manager.nodeMgr.Add(session.NewNodeInfo(session.ImmutableNodeInfo{
NodeID: 1,
Address: "localhost",
Hostname: "localhost",
}))
suite.manager.HandleNodeUp(1)

mockKV.EXPECT().MultiSave(mock.Anything).Return(merr.WrapErrServiceInternal("mocked")).Once()

suite.Panics(func() {
suite.manager.HandleNodeDown(1)
})
}

0 comments on commit 07c25a1

Please sign in to comment.