-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enhance: add create segment message, enable empty segment flush #37407
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,6 +129,14 @@ func WithNoSyncingTask() SegmentFilter { | |
|
||
type SegmentAction func(info *SegmentInfo) | ||
|
||
func SegmentActions(actions ...SegmentAction) SegmentAction { | ||
return func(info *SegmentInfo) { | ||
for _, act := range actions { | ||
act(info) | ||
} | ||
} | ||
} | ||
|
||
func UpdateState(state commonpb.SegmentState) SegmentAction { | ||
return func(info *SegmentInfo) { | ||
info.state = state | ||
|
@@ -147,6 +155,14 @@ func UpdateNumOfRows(numOfRows int64) SegmentAction { | |
} | ||
} | ||
|
||
func SetStartPositionIfNil(startPos *msgpb.MsgPosition) SegmentAction { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setup startPosition when first insert message comes, applied to writebuffer |
||
return func(info *SegmentInfo) { | ||
if info.startPosition == nil { | ||
info.startPosition = startPos | ||
} | ||
} | ||
} | ||
|
||
func UpdateBufferedRows(bufferedRows int64) SegmentAction { | ||
return func(info *SegmentInfo) { | ||
info.bufferRows = bufferedRows | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,7 @@ type ddNode struct { | |
|
||
dropMode atomic.Value | ||
compactionExecutor compaction.Executor | ||
flushMsgHandler flusher.FlushMsgHandler | ||
msgHandler flusher.MsgHandler | ||
|
||
// for recovery | ||
growingSegInfo map[typeutil.UniqueID]*datapb.SegmentInfo // segmentID | ||
|
@@ -236,6 +236,19 @@ func (ddn *ddNode) Operate(in []Msg) []Msg { | |
WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), metrics.DeleteLabel). | ||
Add(float64(dmsg.GetNumRows())) | ||
fgMsg.DeleteMessages = append(fgMsg.DeleteMessages, dmsg) | ||
case commonpb.MsgType_CreateSegment: | ||
createSegment := msg.(*adaptor.CreateSegmentMessageBody) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. create new segment when create segment incoming. |
||
logger := log.With( | ||
zap.String("vchannel", ddn.Name()), | ||
zap.Int32("msgType", int32(msg.Type())), | ||
zap.Uint64("timetick", createSegment.CreateSegmentMessage.TimeTick()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. better to log segmentID as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fix it soon |
||
) | ||
logger.Info("receive create segment message") | ||
if err := ddn.msgHandler.HandleCreateSegment(context.Background(), ddn.vChannelName, createSegment.CreateSegmentMessage); err != nil { | ||
logger.Warn("handle create segment message failed", zap.Error(err)) | ||
} else { | ||
logger.Info("handle create segment message success") | ||
} | ||
case commonpb.MsgType_FlushSegment: | ||
flushMsg := msg.(*adaptor.FlushMessageBody) | ||
logger := log.With( | ||
|
@@ -244,7 +257,7 @@ func (ddn *ddNode) Operate(in []Msg) []Msg { | |
zap.Uint64("timetick", flushMsg.FlushMessage.TimeTick()), | ||
) | ||
logger.Info("receive flush message") | ||
if err := ddn.flushMsgHandler.HandleFlush(ddn.vChannelName, flushMsg.FlushMessage); err != nil { | ||
if err := ddn.msgHandler.HandleFlush(ddn.vChannelName, flushMsg.FlushMessage); err != nil { | ||
logger.Warn("handle flush message failed", zap.Error(err)) | ||
} else { | ||
logger.Info("handle flush message success") | ||
|
@@ -258,7 +271,7 @@ func (ddn *ddNode) Operate(in []Msg) []Msg { | |
zap.Uint64("flushTs", manualFlushMsg.ManualFlushMessage.Header().FlushTs), | ||
) | ||
logger.Info("receive manual flush message") | ||
if err := ddn.flushMsgHandler.HandleManualFlush(ddn.vChannelName, manualFlushMsg.ManualFlushMessage); err != nil { | ||
if err := ddn.msgHandler.HandleManualFlush(ddn.vChannelName, manualFlushMsg.ManualFlushMessage); err != nil { | ||
logger.Warn("handle manual flush message failed", zap.Error(err)) | ||
} else { | ||
logger.Info("handle manual flush message success") | ||
|
@@ -318,7 +331,7 @@ func (ddn *ddNode) Close() { | |
} | ||
|
||
func newDDNode(ctx context.Context, collID typeutil.UniqueID, vChannelName string, droppedSegmentIDs []typeutil.UniqueID, | ||
sealedSegments []*datapb.SegmentInfo, growingSegments []*datapb.SegmentInfo, executor compaction.Executor, handler flusher.FlushMsgHandler, | ||
sealedSegments []*datapb.SegmentInfo, growingSegments []*datapb.SegmentInfo, executor compaction.Executor, handler flusher.MsgHandler, | ||
) (*ddNode, error) { | ||
baseNode := BaseNode{} | ||
baseNode.SetMaxQueueLength(paramtable.Get().DataNodeCfg.FlowGraphMaxQueueLength.GetAsInt32()) | ||
|
@@ -333,7 +346,7 @@ func newDDNode(ctx context.Context, collID typeutil.UniqueID, vChannelName strin | |
droppedSegmentIDs: droppedSegmentIDs, | ||
vChannelName: vChannelName, | ||
compactionExecutor: executor, | ||
flushMsgHandler: handler, | ||
msgHandler: handler, | ||
} | ||
|
||
dd.dropMode.Store(false) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used to set a empty segment into dropped when savebinlogpath