Skip to content

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

Closed
@aBreaking

Description

@aBreaking

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;
            }

请确认...

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategory issues or prs related to bug.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions