You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2021/08/19 03:42:23 UTC

[servicecomb-java-chassis] branch 1.3.x updated: [SCB-2069][SCB-2113][SCB-2127]throw exception in event-loop, fix readme error, not isolate service when timeout (#2517)

This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch 1.3.x
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git


The following commit(s) were added to refs/heads/1.3.x by this push:
     new 74d0dfb  [SCB-2069][SCB-2113][SCB-2127]throw exception in event-loop,fix readme error,not isolate service when timeout (#2517)
74d0dfb is described below

commit 74d0dfb73f3f17b0db11e8cd88255ea5c9e6862d
Author: david6969xin <86...@users.noreply.github.com>
AuthorDate: Thu Aug 19 11:42:18 2021 +0800

    [SCB-2069][SCB-2113][SCB-2127]throw exception in event-loop,fix readme error,not isolate service when timeout (#2517)
---
 .../servicecomb/core/provider/consumer/InvokerUtils.java      | 11 +++++++++++
 handlers/handler-bizkeeper/readme.MD                          |  3 +--
 .../apache/servicecomb/loadbalance/LoadbalanceHandler.java    |  3 ++-
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/core/src/main/java/org/apache/servicecomb/core/provider/consumer/InvokerUtils.java b/core/src/main/java/org/apache/servicecomb/core/provider/consumer/InvokerUtils.java
index 17ffcb2..73df3ce 100644
--- a/core/src/main/java/org/apache/servicecomb/core/provider/consumer/InvokerUtils.java
+++ b/core/src/main/java/org/apache/servicecomb/core/provider/consumer/InvokerUtils.java
@@ -29,9 +29,17 @@ import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.netflix.config.DynamicPropertyFactory;
+
+import io.vertx.core.Context;
+
 public final class InvokerUtils {
   private static final Logger LOGGER = LoggerFactory.getLogger(InvokerUtils.class);
 
+  private static boolean enableEventLoopBlockingCallCheck =
+      DynamicPropertyFactory.getInstance()
+          .getBooleanProperty("servicecomb.invocation.enableEventLoopBlockingCallCheck", true).get();
+
   public static Object syncInvoke(String microserviceName, String schemaId, String operationName, Object[] args) {
     ReferenceConfig referenceConfig = SCBEngine.getInstance().getReferenceConfigForInvoke(microserviceName);
     return syncInvoke(generateInvocation(schemaId, operationName, args, referenceConfig));
@@ -65,6 +73,9 @@ public final class InvokerUtils {
    */
   public static Response innerSyncInvoke(Invocation invocation) {
     try {
+      if (Context.isOnEventLoopThread() && enableEventLoopBlockingCallCheck) {
+        throw new IllegalStateException("Can not execute sync logic in event loop. ");
+      }
       invocation.onStart(null, System.nanoTime());
       SyncResponseExecutor respExecutor = new SyncResponseExecutor();
       invocation.setResponseExecutor(respExecutor);
diff --git a/handlers/handler-bizkeeper/readme.MD b/handlers/handler-bizkeeper/readme.MD
index 698fc80..9874992 100644
--- a/handlers/handler-bizkeeper/readme.MD
+++ b/handlers/handler-bizkeeper/readme.MD
@@ -1,3 +1,2 @@
 参考: 
-hystrix: https://github.com/Netflix/Hystrix/wiki
-design: http://code.huawei.com/CSE/CSE/wikis/design
\ No newline at end of file
+hystrix: https://github.com/Netflix/Hystrix/wiki
\ No newline at end of file
diff --git a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/LoadbalanceHandler.java b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/LoadbalanceHandler.java
index 00be81d..3404e52 100644
--- a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/LoadbalanceHandler.java
+++ b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/LoadbalanceHandler.java
@@ -413,7 +413,8 @@ public class LoadbalanceHandler implements Handler {
       if (InvocationException.class.isInstance(resp.getResult())) {
         InvocationException e = (InvocationException) resp.getResult();
         return e.getStatusCode() == ExceptionFactory.CONSUMER_INNER_STATUS_CODE
-            || e.getStatusCode() == 503;
+            || e.getStatusCode() == 503
+            || e.getStatusCode() == Status.REQUEST_TIMEOUT.getStatusCode();
       } else {
         return true;
       }