alibaba / alibaba/Sentinel

Concurrency problem in NettyTransportClient of sentinel-cluster-client-default

Open
#2,852 0 comments 0 reactions 0 assignees View on GitHub
area/cluster-flow
Dominant language
Java
Stars
23.1k
Forks
8.1k
PR merge metrics
No merged PRs in 30d

Description

```
// https://github.com/alibaba/Sentinel/blob/bef6574734bc75953202079dc0a44aa5dff78157/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/NettyTransportClient.java#L222

channel.writeAndFlush(request);

ChannelPromise promise = channel.newPromise();
TokenClientPromiseHolder.putPromise(xid, promise); // 1、should before writeAndFlush to avoid concurrency problem

if (!promise.await(ClusterClientConfigManager.getRequestTimeout())) {
throw new SentinelClusterException(ClusterErrorMessages.REQUEST_TIME_OUT); // 3、timeout exception
}
```

```
// https://github.com/alibaba/Sentinel/blob/bef6574734bc75953202079dc0a44aa5dff78157/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/handler/TokenClientPromiseHolder.java#L47

if (!PROMISE_MAP.containsKey(xid)) {
return false; // 2、we can't complete the promise
}
```

Contributor guide

Open the contributing guide

Research direction

Read sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/NettyTransportClient.java around line 222 and TokenClientPromiseHolder.java around line 47. Trace the request and promise-registration sequence, then inspect the existing client tests or run the relevant module tests. Done means the promise is available before a response can be processed, so the concurrency race cannot leave it incomplete.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
distributed-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.