pengyu0929 opened a new issue #571: omega 开启 hystrix,使用Feign调用bug
URL: https://github.com/apache/servicecomb-pack/issues/571
 
 
   有两个服务 A、B,A服务开启hystrix,并且设置threadpool参数,如下:
   ```
   feign:
     hystrix:
       enabled: true
   
   hystrix:
     threadpool:
       default:
         coreSize: 3
         maximumSize: 5
     command:
       default:
         execution:
           isolation:
             thread:
               timeoutInMilliseconds: 
${HYSTRIX_COMMAND_TIMEOUT_IN_MILLISECONDS:40000}
   ```
   
在调用次数大于coreSize时,之后的每次调用,omega设置到feign调用的header中的globalTxId均为第三次(即coreSize的值)的globalTxId,现象如下:
   ```
   第三次:
   2019-10-15 10:17:09.881 DEBUG 5604 --- [nio-8300-exec-6] 
o.a.s.p.o.transaction.SagaStartAspect    : Initialized context 
OmegaContext{globalTxId=`2522c732-a7e2-46f2-91c9-7ffcbce2a2b7`, 
localTxId=2522c732-a7e2-46f2-91c9-7ffcbce2a2b7} before execution of method 
public java.lang.String 
com.example.booking.service.BookingServiceImpl.booking(java.lang.String)
    : 开始预定。。。
   2019-10-15 10:17:09.883 DEBUG 5604 --- [  hystrix-car-3] 
.s.p.o.t.f.FeignClientRequestInterceptor : Added X-Pack-Global-Transaction-Id 
`2522c732-a7e2-46f2-91c9-7ffcbce2a2b7` and X-Pack-Local-Transaction-Id 
2522c732-a7e2-46f2-91c9-7ffcbce2a2b7 to request header
   2019-10-15 10:17:09.945 DEBUG 5604 --- [hystrix-hotel-3] 
.s.p.o.t.f.FeignClientRequestInterceptor : Added X-Pack-Global-Transaction-Id 
`2522c732-a7e2-46f2-91c9-7ffcbce2a2b7` and X-Pack-Local-Transaction-Id 
2522c732-a7e2-46f2-91c9-7ffcbce2a2b7 to request header
   ```
   ```
   第四次及之后:
   2019-10-15 10:17:12.176 DEBUG 5604 --- [io-8300-exec-10] 
o.a.s.p.o.transaction.SagaStartAspect    : Initialized context 
OmegaContext{globalTxId=`5a9a3533-86dc-4631-881f-d402e2895307`, 
localTxId=5a9a3533-86dc-4631-881f-d402e2895307} before execution of method 
public java.lang.String 
com.example.booking.service.BookingServiceImpl.booking(java.lang.String)
    : 开始预定。。。
   2019-10-15 10:17:12.176 DEBUG 5604 --- [  hystrix-car-3] 
.s.p.o.t.f.FeignClientRequestInterceptor : Added X-Pack-Global-Transaction-Id 
`2522c732-a7e2-46f2-91c9-7ffcbce2a2b7` and X-Pack-Local-Transaction-Id 
2522c732-a7e2-46f2-91c9-7ffcbce2a2b7 to request header
   2019-10-15 10:17:12.229 DEBUG 5604 --- [hystrix-hotel-3] 
.s.p.o.t.f.FeignClientRequestInterceptor : Added X-Pack-Global-Transaction-Id 
`2522c732-a7e2-46f2-91c9-7ffcbce2a2b7` and X-Pack-Local-Transaction-Id 
2522c732-a7e2-46f2-91c9-7ffcbce2a2b7 to request header
   ```
   这个日志是我本地的测试demo;但是在我们的开发环境有时会出现 globalTxId 为null 的情况;
   我猜测是不是和OmegaContxt中使用的 `InheritableThreadLocal`  有关系,或者存在不知的bug?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to