diff --git a/cluster/cluster_impl/failback_cluster_invoker.go b/cluster/cluster_impl/failback_cluster_invoker.go index 7b88f72ed8..b2fab65c4b 100644 --- a/cluster/cluster_impl/failback_cluster_invoker.go +++ b/cluster/cluster_impl/failback_cluster_invoker.go @@ -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" ) @@ -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) + } } } @@ -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{} @@ -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) }