fix: return collection on recovering but not collection not loaded when target is not recovered (#32447)

issue: #32398

Signed-off-by: chyezh <chyezh@outlook.com>
pull/32601/head
chyezh 2024-04-25 11:21:26 +08:00 committed by GitHub
parent f30c22626e
commit b287fbaa2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 3 deletions

View File

@ -913,9 +913,9 @@ func (s *Server) GetShardLeaders(ctx context.Context, req *querypb.GetShardLeade
channels := s.targetMgr.GetDmChannelsByCollection(req.GetCollectionID(), meta.CurrentTarget)
if len(channels) == 0 {
msg := "failed to get channels"
err := merr.WrapErrCollectionNotLoaded(req.GetCollectionID())
log.Warn(msg, zap.Error(err))
err := merr.WrapErrCollectionOnRecovering(req.GetCollectionID(),
"loaded collection do not found any channel in target, may be in recovery")
log.Warn("failed to get channels", zap.Error(err))
resp.Status = merr.Status(err)
return resp, nil
}

View File

@ -51,6 +51,7 @@ var (
ErrCollectionNotFullyLoaded = newMilvusError("collection not fully loaded", 103, true)
ErrCollectionLoaded = newMilvusError("collection already loaded", 104, false)
ErrCollectionIllegalSchema = newMilvusError("illegal collection schema", 105, false)
ErrCollectionOnRecovering = newMilvusError("collection on recovering", 106, true)
// Partition related
ErrPartitionNotFound = newMilvusError("partition not found", 200, false)

View File

@ -86,6 +86,7 @@ func (s *ErrSuite) TestWrap() {
s.ErrorIs(WrapErrCollectionNotLoaded("test_collection", "failed to query"), ErrCollectionNotLoaded)
s.ErrorIs(WrapErrCollectionNotFullyLoaded("test_collection", "failed to query"), ErrCollectionNotFullyLoaded)
s.ErrorIs(WrapErrCollectionNotLoaded("test_collection", "failed to alter index %s", "hnsw"), ErrCollectionNotLoaded)
s.ErrorIs(WrapErrCollectionOnRecovering("test_collection", "channel lost %s", "dev"), ErrCollectionOnRecovering)
// Partition related
s.ErrorIs(WrapErrPartitionNotFound("test_partition", "failed to get partition"), ErrPartitionNotFound)

View File

@ -479,6 +479,16 @@ func WrapErrCollectionIllegalSchema(collection string, msgAndArgs ...any) error
return err
}
// WrapErrCollectionOnRecovering wraps ErrCollectionOnRecovering with collection
func WrapErrCollectionOnRecovering(collection any, msgAndArgs ...any) error {
err := wrapFields(ErrCollectionOnRecovering, value("collection", collection))
if len(msgAndArgs) > 0 {
msg := msgAndArgs[0].(string)
err = errors.Wrapf(err, msg, msgAndArgs[1:]...)
}
return err
}
func WrapErrAliasNotFound(db any, alias any, msg ...string) error {
err := wrapFields(ErrAliasNotFound,
value("database", db),