未验证 提交 3630eec9 编写于 作者: X xige-16 提交者: GitHub

Fix receving wrong msg after seek (#5441)

Signed-off-by: Nxige-16 <xi.ge@zilliz.com>
上级 9aa1fd25
......@@ -102,8 +102,7 @@ func (ms *mqMsgStream) AsProducer(channels []string) {
}
}
func (ms *mqMsgStream) AsConsumer(channels []string,
subName string) {
func (ms *mqMsgStream) AsConsumer(channels []string, subName string) {
for _, channel := range channels {
if _, ok := ms.consumers[channel]; ok {
continue
......@@ -190,14 +189,14 @@ func (ms *mqMsgStream) GetProduceChannels() []string {
}
func (ms *mqMsgStream) Produce(msgPack *MsgPack) error {
tsMsgs := msgPack.Msgs
if len(tsMsgs) <= 0 {
if msgPack == nil || len(msgPack.Msgs) <= 0 {
log.Debug("Warning: Receive empty msgPack")
return nil
}
if len(ms.producers) <= 0 {
return errors.New("nil producer in msg stream")
}
tsMsgs := msgPack.Msgs
reBucketValues := ms.ComputeProduceChannelIndexes(msgPack.Msgs)
var result map[int32]*MsgPack
var err error
......@@ -251,6 +250,10 @@ func (ms *mqMsgStream) Produce(msgPack *MsgPack) error {
}
func (ms *mqMsgStream) Broadcast(msgPack *MsgPack) error {
if msgPack == nil || len(msgPack.Msgs) <= 0 {
log.Debug("Warning: Receive empty msgPack")
return nil
}
for _, v := range msgPack.Msgs {
sp, spanCtx := MsgSpanFromCtx(v.TraceCtx(), v)
......@@ -479,7 +482,6 @@ func (ms *MqTtMsgStream) Close() {
func (ms *MqTtMsgStream) bufMsgPackToChannel() {
defer ms.wait.Done()
ms.unsolvedBuf = make(map[mqclient.Consumer][]TsMsg)
isChannelReady := make(map[mqclient.Consumer]bool)
eofMsgTimeStamp := make(map[mqclient.Consumer]Timestamp)
......@@ -503,11 +505,11 @@ func (ms *MqTtMsgStream) bufMsgPackToChannel() {
wg.Add(1)
go ms.findTimeTick(consumer, eofMsgTimeStamp, &wg, &findMapMutex)
}
ms.consumerLock.Unlock()
wg.Wait()
timeStamp, ok := checkTimeTickMsg(eofMsgTimeStamp, isChannelReady, &findMapMutex)
if !ok || timeStamp <= ms.lastTimeStamp {
//log.Printf("All timeTick's timestamps are inconsistent")
ms.consumerLock.Unlock()
continue
}
timeTickBuf := make([]TsMsg, 0)
......@@ -553,6 +555,7 @@ func (ms *MqTtMsgStream) bufMsgPackToChannel() {
ms.msgPositions[consumer] = newPos
}
ms.unsolvedMutex.Unlock()
ms.consumerLock.Unlock()
msgPack := MsgPack{
BeginTs: ms.lastTimeStamp,
......@@ -712,9 +715,9 @@ func (ms *MqTtMsgStream) Seek(mp *internalpb.MsgPosition) error {
ms.addConsumer(consumer, seekChannel)
//TODO: May cause problem
if len(consumer.Chan()) == 0 {
return nil
}
//if len(consumer.Chan()) == 0 {
// return nil
//}
for {
select {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册