apache / apache/servicecomb-java-chassis
微服务实例查询更新存在并发问题,导致先查询的实例状态后更新的问题
- Dominant language
- Java
- Stars
- 1.9k
- Forks
- 814
- Avg merge
- 8d 23h
- Merged PRs (30d)
- 1
Description
分析ServiceComb 的源码(1.3.8),发现实例查找存在并发问题,导致出现先查询的实例状态后更新的问题。
触发实例查找和更新主要有两个触发源
1)周期查询更新
2)watch触发
不同的来源会在Service Center Task线程池提交查询更新任务,且可能在不同线程中并发执行,主要步骤为:
```bash
触发源(周期/watch) ---> 注册中心查询实例信息 ---> 实例状态更新到本地缓存
```
从代码看,只有更新本地实例状态时才会有锁同步操作,查询实例则可能并发执行。由于线程调度切换问题,因此即使是先查询到的实例状态结果,也有可能被后更新,导致以上结果。
此问题在注册中心实例watch模式下,多个实例同时下线时容易复现,请求会发到已下线的节点而失败。
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing the ServiceComb 1.3.8 instance lookup and local-cache update flow for both periodic refreshes and watch-triggered tasks. Reproduce concurrent updates while multiple instances go offline; done means an older lookup result cannot overwrite a newer instance state and requests are not sent to nodes already marked offline.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100