Set BaseMsg for LoadSegmentRequest, prevent crashing in log printing (#15725)

Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
pull/15614/merge
bigsheeper 2022-02-26 20:09:54 +08:00 committed by GitHub
parent de4c922950
commit 6a48071a5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View File

@ -60,6 +60,10 @@ type segmentLoader struct {
}
func (loader *segmentLoader) loadSegment(req *querypb.LoadSegmentsRequest, segmentType segmentType) error {
if req.Base == nil {
return fmt.Errorf("nil base message when load segment, collectionID = %d", req.CollectionID)
}
// no segment needs to load, return
if len(req.Infos) == 0 {
return nil

View File

@ -99,6 +99,19 @@ func TestSegmentLoader_loadSegment(t *testing.T) {
err = loader.loadSegment(req, segmentTypeSealed)
assert.Error(t, err)
})
t.Run("test load segment with nil base message", func(t *testing.T) {
node, err := genSimpleQueryNode(ctx)
assert.NoError(t, err)
loader := node.loader
assert.NotNil(t, loader)
req := &querypb.LoadSegmentsRequest{}
err = loader.loadSegment(req, segmentTypeSealed)
assert.Error(t, err)
})
}
func TestSegmentLoader_loadSegmentFieldsData(t *testing.T) {

View File

@ -27,6 +27,7 @@ import (
"go.uber.org/zap"
"github.com/milvus-io/milvus/internal/log"
"github.com/milvus-io/milvus/internal/proto/commonpb"
"github.com/milvus-io/milvus/internal/proto/datapb"
"github.com/milvus-io/milvus/internal/proto/internalpb"
queryPb "github.com/milvus-io/milvus/internal/proto/querypb"
@ -279,6 +280,10 @@ func (w *watchDmChannelsTask) Execute(ctx context.Context) error {
}
}
req := &queryPb.LoadSegmentsRequest{
Base: &commonpb.MsgBase{
MsgType: commonpb.MsgType_LoadSegments,
MsgID: w.req.Base.MsgID, // use parent task's msgID
},
Infos: unFlushedSegments,
CollectionID: collectionID,
Schema: w.req.Schema,