未验证 提交 6a48071a 编写于 作者: B bigsheeper 提交者: GitHub

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

Signed-off-by: Nbigsheeper <yihao.dai@zilliz.com>
上级 de4c9229
......@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册