Sentinel Circuit breaking was not triggered with Spring WebFlux and reactive WebClient

9rygscc1  于 2021-11-29  发布在  Java
关注(0)|答案(20)|浏览(398)

Issue Description

Type: bug report or feature request

Describe what happened (or what feature you want)

SphU.asyncEntry 接口无法block

Describe what you expected to happen

我写了个服务接口,delay 1秒

使用如下的方法测试,资源设置50ms超时,时间窗口2秒

日志显示
没有请求block,所有请求都成功到达后端

How to reproduce it (as minimally and precisely as possible)

  1. 写一个缓慢的服务端,我采用delay 1秒模拟
  2. 使用webflux webclient 请求服务,订阅里close AsyncEntry
  3. 循环调用多次,我测试是调用100次

Tell us your environment

jdk 14, kotlin 1.3.71, win 10 64 bit

Anything else we need to know?

a64a0gku

a64a0gku16#

kotlin和reactor都有一套context,spring 通过判断类型来决定使用同步的thread local或者使用异步的XXXContext
https://spring.io/blog/2019/05/16/reactive-transactions-with-spring

q5iwbnjs

q5iwbnjs17#

同样配置异步的不触发熔断,所有请求都会发送到后端,同步请求触发熔断,所以应该不是配置的问题,我的配置如下
resource: zlw-get-user-pig-factory-list-api
count: 100.0
timeWindow: 2

tvz2xvvm

tvz2xvvm18#

我觉得使用thread local的方式有问题,使用协程,多个方法可能走到同一个线程

bn31dyow

bn31dyow19#

参考文档看看是否满足触发条件:https://github.com/alibaba/Sentinel/wiki/熔断降级
1.8.0 版本会对 RT 模式进行改进

ruoxqz4g

ruoxqz4g20#

1秒的接口延时应该还算合理,我在调用处加了sleep依然没有block住

相关问题