mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-02 11:59:00 +08:00
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:
parent
35b7267edb
commit
2879796b42
@ -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
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user