Validate partitionIDs & segmentIDs in query request (#16684)

* check partitions if they are released or unloaded
    * check segments if their collection/partition(s) are released or unloaded

Signed-off-by: Letian Jiang <letian.jiang@zilliz.com>
This commit is contained in:
Letian Jiang 2022-04-27 19:23:48 +08:00 committed by GitHub
parent 35b7267edb
commit 2879796b42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -844,7 +844,13 @@ func (q *queryShard) query(ctx context.Context, req *querypb.QueryRequest) (*int
// hold request until guarantee timestamp >= service timestamp
guaranteeTs := req.GetReq().GetGuaranteeTimestamp()
q.waitUntilServiceable(ctx, guaranteeTs, tsTypeDelta)
// shard follower considers solely historical segments
// validate segmentIDs in request
err = q.historical.validateSegmentIDs(segmentIDs, collectionID, partitionIDs)
if err != nil {
log.Warn("segmentIDs in query request fails validation", zap.Int64s("segmentIDs", segmentIDs))
return nil, err
}
retrieveResults, err := q.historical.retrieveBySegmentIDs(collectionID, segmentIDs, q.vectorChunkManager, plan)
if err != nil {
return nil, err

View File

@ -138,6 +138,17 @@ func TestQueryShard_Query(t *testing.T) {
assert.ElementsMatch(t, resp.Ids.GetIntId().Data, []int64{1, 2, 3})
})
t.Run("query follower with wrong segment", func(t *testing.T) {
request := &querypb.QueryRequest{
Req: req,
DmlChannel: "",
SegmentIDs: []int64{defaultSegmentID + 1},
}
_, err := qs.query(context.Background(), request)
assert.Error(t, err)
})
t.Run("query leader", func(t *testing.T) {
request := &querypb.QueryRequest{
Req: req,