Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1. avoid cancel context too early cause trace data fail.
  • Loading branch information
wangjinlong.1048576 committed Jul 18, 2022
commit 35b951d0396170877dbb58a4708e7c96af7221e9
2 changes: 1 addition & 1 deletion consumer/push_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ func (pc *pushConsumer) consumeMessageOrderly(pq *processQueue, mq *primitive.Me
})
}

// jsut put consumeResult in consumerMessageCtx
// just put consumeResult in consumerMessageCtx
//interval = time.Now().Sub(beginTime)
//consumeReult := SuccessReturn
//if interval > pc.option.ConsumeTimeout {
Expand Down
3 changes: 2 additions & 1 deletion internal/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,8 @@ func (td *traceDispatcher) sendTraceDataByMQ(keySet Keyset, regionID string, dat

var req = td.buildSendRequest(mq, msg)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
err := td.cli.InvokeAsync(ctx, addr, req, func(command *remote.RemotingCommand, e error) {
cancel()
resp := primitive.NewSendResult()
if e != nil {
rlog.Info("send trace data error.", map[string]interface{}{
Expand All @@ -479,6 +479,7 @@ func (td *traceDispatcher) sendTraceDataByMQ(keySet Keyset, regionID string, dat
}
})
if err != nil {
cancel()
rlog.Info("send trace data error when invoke", map[string]interface{}{
rlog.LogKeyUnderlayError: err,
})
Expand Down
13 changes: 10 additions & 3 deletions producer/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,9 @@ func (p *defaultProducer) sendAsync(ctx context.Context, msg *primitive.Message,
return errors.Errorf("topic=%s route info not found", mq.Topic)
}

ctx, _ = context.WithTimeout(ctx, 3*time.Second)
return p.client.InvokeAsync(ctx, addr, p.buildSendRequest(mq, msg), func(command *remote.RemotingCommand, err error) {
ctx, cancel := context.WithTimeout(ctx, 3*time.Second)
err := p.client.InvokeAsync(ctx, addr, p.buildSendRequest(mq, msg), func(command *remote.RemotingCommand, err error) {
cancel()
resp := primitive.NewSendResult()
if err != nil {
h(ctx, nil, err)
Expand All @@ -263,6 +264,12 @@ func (p *defaultProducer) sendAsync(ctx context.Context, msg *primitive.Message,
h(ctx, resp, nil)
}
})

if err != nil {
cancel()
}

return err
}

func (p *defaultProducer) SendOneWay(ctx context.Context, msgs ...*primitive.Message) error {
Expand Down Expand Up @@ -347,7 +354,7 @@ func (p *defaultProducer) buildSendRequest(mq *primitive.MessageQueue,
}

var (
sysFlag = 0
sysFlag = 0
transferBody = msg.Body
)

Expand Down