alibaba / alibaba/Sentinel

Downgrade function extension discussion

Open
#868 3 comments 0 reactions 0 assignees View on GitHub
area/circuit-breaking kind/discussion kind/enhancement
Dominant language
Java
Stars
23.1k
Forks
8.1k
PR merge metrics
No merged PRs in 30d

Description

## Issue Description

Type: *feature request*

### Describe what happened (or what feature you want)

now the sentinel degrade logic is as bellow

```
Public static void trace(Throwable e): record business exception (not BlockException)
Public static void trace(Throwable e, int count): Records the business exception. The number of exceptions is the counted in.
```

```
public boolean passCheck(Context context, DefaultNode node, int acquireCount, Object... args) {
if (cut.get()) {
return false;
}

ClusterNode clusterNode = ClusterBuilderSlot.getClusterNode(this.getResource());
if (clusterNode == null) {
return true;
}

if (grade == RuleConstant.DEGRADE_GRADE_RT) {
double rt = clusterNode.avgRt();
if (rt < this.count) {
passCount.set(0);
return true;
}

// Sentinel will degrade the service only if count exceeds.
if (passCount.incrementAndGet() < rtSlowRequestAmount) {
return true;
}
} else if (grade == RuleConstant.DEGRADE_GRADE_EXCEPTION_RATIO) {
double exception = clusterNode.exceptionQps();
double success = clusterNode.successQps();
double total = clusterNode.totalQps();
// If total amount is less than minRequestAmount, the request will pass.
if (total < minRequestAmount) {
return true;
}

// In the same aligned statistic time window,
// "success" (aka. completed count) = exception count + non-exception count (realSuccess)
double realSuccess = success - exception;
if (realSuccess <= 0 && exception < minRequestAmount) {
return true;
}

if (exception / success < count) {
return true;
}
} else if (grade == RuleConstant.DEGRADE_GRADE_EXCEPTION_COUNT) {
double exception = clusterNode.totalException();
if (exception < count) {
return true;
}
}

if (cut.compareAndSet(false, true)) {
ResetTask resetTask = new ResetTask(this);
pool.schedule(resetTask, timeWindow, TimeUnit.SECONDS);
}

return false;
}
```
does any body found that : it's exception statistics is not distinguish the type。Actually exception can be divided into many types. The first is not a real exception, but it means that the processing result fails or succeeds.for example, some parameter verification fails or the business data status is incorrect, exceptions like that should not trigger the degrade. The second is the normal exception we think of, such as timeout or system error. It is ok to trigger service degrade. There is also a fatal exception and an exception that says the business can't be recovered for a long time. Once this exception occurs, we should immediately downgrade,rather thanAccumulate to a certain extent before degrading

### Describe what you expected to happen

so I hope sentinel should make a more refined management of the downgrade exception.

Contributor guide

Open the contributing guide

Research direction

Start by reading the passCheck method and the trace(Throwable e) and trace(Throwable e, int count) entry points described in the issue, along with ClusterNode and RuleConstant usage. Clarify the proposed exception categories and their intended degradation behavior before identifying the affected Sentinel components. Done requires an agreed design and corresponding tests for each category.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, distributed-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.