mirror of https://github.com/milvus-io/milvus.git
Set BaseMsg for LoadSegmentRequest, prevent crashing in log printing (#15725)
Signed-off-by: bigsheeper <yihao.dai@zilliz.com>pull/15614/merge
parent
de4c922950
commit
6a48071a5c
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue