Skip to content

Commit

Permalink
fix according review
Browse files Browse the repository at this point in the history
  • Loading branch information
xujianhai666 committed Jul 26, 2019
1 parent 6a4b0b1 commit 6ff4bcf
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions cluster/cluster_impl/failback_cluster_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/apache/dubbo-go/cluster"
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/extension"
"github.com/apache/dubbo-go/common/logger"
"github.com/apache/dubbo-go/protocol"
)

Expand Down Expand Up @@ -88,21 +89,24 @@ func (invoker *failbackClusterInvoker) process() {

invoker.taskList.pop()

invoked := []protocol.Invoker{}
invoked = append(invoked, retryTask.lastInvoker)

err := invoker.checkWhetherDestroyed()
if err != nil {
invoker.checkRetry(retryTask, err)
return
}

retryInvoker := invoker.doSelect(retryTask.loadbalance, retryTask.invocation, retryTask.invokers, invoked)
var result protocol.Result
result = retryInvoker.Invoke(retryTask.invocation)
if result.Error() != nil {
invoker.checkRetry(retryTask, result.Error())
}
go func(retryTask *retryTimerTask) {
invoked := []protocol.Invoker{}
invoked = append(invoked, retryTask.lastInvoker)

retryInvoker := invoker.doSelect(retryTask.loadbalance, retryTask.invocation, retryTask.invokers, invoked)
var result protocol.Result
result = retryInvoker.Invoke(retryTask.invocation)
if result.Error() != nil {
invoker.checkRetry(retryTask, result.Error())
}
}(retryTask)

}
}
}
Expand All @@ -125,7 +129,6 @@ func (invoker *failbackClusterInvoker) Invoke(invocation protocol.Invocation) pr
err := invoker.checkInvokers(invokers, invocation)

if err != nil {
// add retry ticker task
perrors.Errorf("Failed to invoke the method %v in the service %v, wait for retry in background. Ignored exception: %v.",
invocation.MethodName(), invoker.GetUrl().Service(), err)
return &protocol.RPCResult{}
Expand Down Expand Up @@ -212,6 +215,9 @@ func newQueue() *Queue {
func (q *Queue) push(v interface{}) {
defer q.Unlock()
q.Lock()
if q.data.Len() > 1000 {
logger.Warnf("retry work in failbackClusterInvoker is too large: %d > 1000", q.data.Len())
}
q.data.PushFront(v)
}

Expand Down

0 comments on commit 6ff4bcf

Please sign in to comment.