mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 17:48:29 +08:00
fix: Fix potential panic when DeleteCheckpoint is nil (#42664)
issue: #42663 Fix panic issue when processing VchannelInfo messages from older coordinator versions that don't have DeleteCheckpoint field. Changes: - Add null safety check for DeleteCheckpoint before accessing methods - Maintain backward compatibility with legacy message formats - Improve seek position selection logic for both old and new versions --------- Signed-off-by: Wei Liu <wei.liu@zilliz.com>
This commit is contained in:
parent
cbed31933a
commit
78c39edbce
@ -324,27 +324,41 @@ func (node *QueryNode) WatchDmChannels(ctx context.Context, req *querypb.WatchDm
|
|||||||
}
|
}
|
||||||
|
|
||||||
var position *msgpb.MsgPosition
|
var position *msgpb.MsgPosition
|
||||||
if channel.GetSeekPosition().GetTimestamp() > channel.GetDeleteCheckpoint().GetTimestamp() {
|
deleteCheckpoint := channel.GetDeleteCheckpoint()
|
||||||
msg := "channel seek position is greater than delete checkpoint, use delete checkpoint to seek"
|
channelCheckpoint := channel.GetSeekPosition()
|
||||||
log.Info(msg,
|
if deleteCheckpoint == nil {
|
||||||
zap.Time("seekPosition", tsoutil.PhysicalTime(channel.GetSeekPosition().GetTimestamp())),
|
// for compatibility with old version coord, which doesn't have delete checkpoint in VchannelInfo
|
||||||
zap.Time("deleteCheckpoint", tsoutil.PhysicalTime(channel.GetDeleteCheckpoint().GetTimestamp())),
|
log.Info("no delete checkpoint found, use seek position to seek",
|
||||||
|
zap.Time("seekPosition", tsoutil.PhysicalTime(channelCheckpoint.GetTimestamp())),
|
||||||
)
|
)
|
||||||
position = &msgpb.MsgPosition{
|
position = &msgpb.MsgPosition{
|
||||||
ChannelName: channel.DeleteCheckpoint.ChannelName,
|
ChannelName: channelCheckpoint.GetChannelName(),
|
||||||
MsgID: channel.DeleteCheckpoint.MsgID,
|
MsgID: channelCheckpoint.GetMsgID(),
|
||||||
Timestamp: channel.DeleteCheckpoint.Timestamp,
|
Timestamp: channelCheckpoint.GetTimestamp(),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if channelCheckpoint.GetTimestamp() > deleteCheckpoint.GetTimestamp() {
|
||||||
|
msg := "channel seek position is greater than delete checkpoint, use delete checkpoint to seek"
|
||||||
|
log.Info(msg,
|
||||||
|
zap.Time("seekPosition", tsoutil.PhysicalTime(channelCheckpoint.GetTimestamp())),
|
||||||
|
zap.Time("deleteCheckpoint", tsoutil.PhysicalTime(deleteCheckpoint.GetTimestamp())),
|
||||||
|
)
|
||||||
|
position = &msgpb.MsgPosition{
|
||||||
|
ChannelName: deleteCheckpoint.GetChannelName(),
|
||||||
|
MsgID: deleteCheckpoint.GetMsgID(),
|
||||||
|
Timestamp: deleteCheckpoint.GetTimestamp(),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
msg := "channel seek position is smaller than delete checkpoint, use seek position to seek"
|
msg := "channel seek position is smaller than delete checkpoint, use seek position to seek"
|
||||||
log.Info(msg,
|
log.Info(msg,
|
||||||
zap.Time("seekPosition", tsoutil.PhysicalTime(channel.GetSeekPosition().GetTimestamp())),
|
zap.Time("seekPosition", tsoutil.PhysicalTime(channelCheckpoint.GetTimestamp())),
|
||||||
zap.Time("deleteCheckpoint", tsoutil.PhysicalTime(channel.GetDeleteCheckpoint().GetTimestamp())),
|
zap.Time("deleteCheckpoint", tsoutil.PhysicalTime(deleteCheckpoint.GetTimestamp())),
|
||||||
)
|
)
|
||||||
position = &msgpb.MsgPosition{
|
position = &msgpb.MsgPosition{
|
||||||
ChannelName: channel.SeekPosition.ChannelName,
|
ChannelName: channelCheckpoint.GetChannelName(),
|
||||||
MsgID: channel.SeekPosition.MsgID,
|
MsgID: channelCheckpoint.GetMsgID(),
|
||||||
Timestamp: channel.SeekPosition.Timestamp,
|
Timestamp: channelCheckpoint.GetTimestamp(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user