mirror of https://github.com/milvus-io/milvus.git
fix collection not exist cause query coord panic (#20553)
Signed-off-by: Wei Liu <wei.liu@zilliz.com> Signed-off-by: Wei Liu <wei.liu@zilliz.com>pull/20566/head
parent
44aed995ae
commit
6a2e458f90
|
@ -46,7 +46,6 @@ import (
|
|||
"github.com/milvus-io/milvus/internal/querycoordv2/params"
|
||||
"github.com/milvus-io/milvus/internal/querycoordv2/session"
|
||||
"github.com/milvus-io/milvus/internal/querycoordv2/task"
|
||||
"github.com/milvus-io/milvus/internal/querycoordv2/utils"
|
||||
"github.com/milvus-io/milvus/internal/types"
|
||||
"github.com/milvus-io/milvus/internal/util/dependency"
|
||||
"github.com/milvus-io/milvus/internal/util/metricsinfo"
|
||||
|
@ -515,9 +514,12 @@ func (s *Server) recover() error {
|
|||
func (s *Server) recoverCollectionTargets(ctx context.Context, collection int64) error {
|
||||
err := s.targetMgr.UpdateCollectionNextTarget(collection)
|
||||
if err != nil {
|
||||
msg := "failed to update next target for collection"
|
||||
log.Error(msg, zap.Error(err))
|
||||
return utils.WrapError(msg, err)
|
||||
s.meta.CollectionManager.RemoveCollection(collection)
|
||||
s.meta.ReplicaManager.RemoveCollection(collection)
|
||||
log.Error("failed to recover collection due to update next target failed",
|
||||
zap.Int64("collectionID", collection),
|
||||
zap.Error(err),
|
||||
)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ package querycoordv2
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -141,6 +142,26 @@ func (suite *ServerSuite) TestRecover() {
|
|||
}
|
||||
}
|
||||
|
||||
func (suite *ServerSuite) TestRecoverFailed() {
|
||||
err := suite.server.Stop()
|
||||
suite.NoError(err)
|
||||
|
||||
suite.server, err = newQueryCoord()
|
||||
suite.NoError(err)
|
||||
|
||||
broker := meta.NewMockBroker(suite.T())
|
||||
broker.EXPECT().GetPartitions(context.TODO(), int64(1000)).Return(nil, errors.New("CollectionNotExist"))
|
||||
broker.EXPECT().GetRecoveryInfo(context.TODO(), int64(1001), mock.Anything).Return(nil, nil, errors.New("CollectionNotExist"))
|
||||
suite.server.targetMgr = meta.NewTargetManager(broker, suite.server.meta)
|
||||
err = suite.server.Start()
|
||||
suite.NoError(err)
|
||||
|
||||
for _, collection := range suite.collections {
|
||||
suite.False(suite.server.meta.Exist(collection))
|
||||
suite.Nil(suite.server.targetMgr.GetDmChannelsByCollection(collection, meta.NextTarget))
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *ServerSuite) TestNodeUp() {
|
||||
newNode := mocks.NewMockQueryNode(suite.T(), suite.server.etcdCli, 100)
|
||||
newNode.EXPECT().GetDataDistribution(mock.Anything, mock.Anything).Return(&querypb.GetDataDistributionResponse{}, nil)
|
||||
|
|
Loading…
Reference in New Issue