fix: Return specific error code when encountering incomplete requery results (#31343)

During requery, segments may change (e.g., due to compaction), so we
need to return specific error codes when encountering incomplete requery
results. Clients can then retry to avoid this issue.

issue: https://github.com/milvus-io/milvus/issues/29656

Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
pull/31363/head
yihao.dai 2024-03-18 14:15:04 +08:00 committed by GitHub
parent 4dfdb1a443
commit c4ace0f9d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 2 deletions

View File

@ -679,8 +679,8 @@ func doRequery(ctx context.Context,
for i := 0; i < typeutil.GetSizeOfIDs(ids); i++ {
id := typeutil.GetPK(ids, int64(i))
if _, ok := offsets[id]; !ok {
return fmt.Errorf("incomplete query result, missing id %s, len(searchIDs) = %d, len(queryIDs) = %d, collection=%d",
id, typeutil.GetSizeOfIDs(ids), len(offsets), collectionID)
return merr.WrapErrInconsistentRequery(fmt.Sprintf("incomplete query result, missing id %s, len(searchIDs) = %d, len(queryIDs) = %d, collection=%d",
id, typeutil.GetSizeOfIDs(ids), len(offsets), collectionID))
}
typeutil.AppendFieldData(result.Results.FieldsData, queryResult.GetFieldsData(), int64(offsets[id]))
}

View File

@ -154,6 +154,9 @@ var (
// import
ErrImportFailed = newMilvusError("importing data failed", 2100, false)
// Search/Query related
ErrInconsistentRequery = newMilvusError("inconsistent requery result", 2200, true)
)
type milvusError struct {

View File

@ -145,6 +145,9 @@ func (s *ErrSuite) TestWrap() {
// alias related
s.ErrorIs(WrapErrAliasNotFound("alias", "failed to get collection id"), ErrAliasNotFound)
s.ErrorIs(WrapErrCollectionIDOfAliasNotFound(1000, "failed to get collection id"), ErrCollectionIDOfAliasNotFound)
// Search/Query related
s.ErrorIs(WrapErrInconsistentRequery("unknown"), ErrInconsistentRequery)
}
func (s *ErrSuite) TestOldCode() {

View File

@ -943,3 +943,11 @@ func WrapErrImportFailed(msg ...string) error {
}
return err
}
func WrapErrInconsistentRequery(msg ...string) error {
err := error(ErrInconsistentRequery)
if len(msg) > 0 {
err = errors.Wrap(err, strings.Join(msg, "->"))
}
return err
}