Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【bug】熔断降级的异常比例为1时,不会被隔离 #128

Closed
aBreaking opened this issue Sep 5, 2018 · 3 comments
Closed

【bug】熔断降级的异常比例为1时,不会被隔离 #128

aBreaking opened this issue Sep 5, 2018 · 3 comments
Labels
kind/bug Category issues or prs related to bug.
Milestone

Comments

@aBreaking
Copy link

extends #109
你好!上次关于#109的这个bug,后来被整改了。

Bug描述

但是整改得并不正确.....经我测试,仅限于异常比例小于1的情况下正确。
但是当抛出的异常比例为100%时,设定的阈值小于1,此时会出现DegradeException,但是服务不会进入timeWindow被隔离。

举个栗子

同样以com.alibaba.csp.sentinel.demo.degrade.ExceptionRatioDegradeDemo这个Demo为例,直接设定每次都抛出异常,结果如下(不知怎么上传图片,直接copy过来了):
Connected to the target VM, address: '127.0.0.1:51393', transport: 'socket' begin to statistic!!! 1536131534343, oneSecondTotal:34, oneSecondPass:5, oneSecondBlock:29, oneSecondBizException:5 1536131535345, oneSecondTotal:49, oneSecondPass:5, oneSecondBlock:44, oneSecondBizException:5 1536131536345, oneSecondTotal:48, oneSecondPass:5, oneSecondBlock:43, oneSecondBizException:5 1536131537344, oneSecondTotal:48, oneSecondPass:5, oneSecondBlock:43, oneSecondBizException:5 1536131538346, oneSecondTotal:49, oneSecondPass:5, oneSecondBlock:44, oneSecondBizException:5 1536131539346, oneSecondTotal:48, oneSecondPass:5, oneSecondBlock:43, oneSecondBizException:5 1536131540346, oneSecondTotal:48, oneSecondPass:5, oneSecondBlock:43, oneSecondBizException:5 1536131541348, oneSecondTotal:49, oneSecondPass:5, oneSecondBlock:44, oneSecondBizException:5 1536131542348, oneSecondTotal:48, oneSecondPass:5, oneSecondBlock:43, oneSecondBizException:5

整改措施

问题还是出在:com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule的passCheck方法中,在原来的Fixed处:commit 6799da2

double realSuccess = success - exception;  //186
            if (realSuccess <= 0) {   //187
                return exception < RT_MAX_EXCEED_N;
            }

不应该修改,还是应该保留原来的代码:

if (success <= 0) {
                return exception < RT_MAX_EXCEED_N;
            }

请确认...

@sczyh30
Copy link
Member

sczyh30 commented Sep 5, 2018

Thanks for reporting! This is due to the early return when no success and exception count does not exceed the threshold. We'll fix it later.

@sczyh30 sczyh30 added the kind/bug Category issues or prs related to bug. label Sep 5, 2018
@sczyh30 sczyh30 added this to the 0.2.0 milestone Sep 5, 2018
@aBreaking
Copy link
Author

by the way,问下哈。目前的熔断降级策略是每秒钟的异常比例不能超过阈值。
那么我怎么设置这个单位时间呢?
比如,我设置每分钟或者每30秒的异常的比例不超过阈值,超过则隔离。
我试着修改,com.alibaba.csp.sentinel.node.IntervalProperty的INTERVAL值,但是好像结果并不是我想要的。
能告知一下这个怎么做吗?
谢谢!

@sczyh30
Copy link
Member

sczyh30 commented Sep 5, 2018

Hi, this is not supported well in current version. You can modify the INTERVAL but it will affect the global counter.

@sczyh30 sczyh30 closed this as completed in ed30f85 Sep 5, 2018
Arlmls pushed a commit to Arlmls/Sentinel that referenced this issue Jan 8, 2019
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Category issues or prs related to bug.
Projects
None yet
Development

No branches or pull requests

2 participants