alibaba / sentinel-golang

Sentinel Go enables reliability and resiliency for Go microservices
https://sentinelguard.io/
Apache License 2.0
2.76k stars 431 forks source link

[BUG] 并发度计算忽略了BatchCount,导致资源隔离异常 #556

Open Levi-Hope opened 7 months ago

Levi-Hope commented 7 months ago

Issue Description

Type: bug report

Describe what happened

并发度计算忽略了BatchCount,但资源隔离考虑了BatchCount,这样会导致资源隔离逻辑出现异常。 比如说IsolationRule阈值为10,调用4次sentinel.Entry("abc", sentinel.WithBatchCount(8)),返回结果是: Pass Pass Pass Block 在第4次Entry才会返回Block,之前的3次Entry都Pass了,通过资源24个,相当于漏限12个资源。

Describe what you expected to happen

并发度计算需要考虑BatchCount。 在上面那个例子里,第2次Entry就应该Block住。

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

我在 这里 里补了一个集成测试,这个测试可以复现。

Tell us your environment

Anything else we need to know?

已提PR https://github.com/alibaba/sentinel-golang/pull/557

Levi-Hope commented 7 months ago

已提PR https://github.com/alibaba/sentinel-golang/pull/557