currentWindow concurrency problem | currentWindow 多线程issue
- Dominant language
- Java
- Stars
- 23.1k
- Forks
- 8.1k
- PR merge metrics
- No merged PRs in 30d
Description
else if (windowStart == old.windowStart()) {
return old;
} else if (windowStart > old.windowStart()) {
if (updateLock.tryLock()) {
try {
// Successfully get the update lock, now we reset the bucket.
return resetWindowTo(old, windowStart);
} finally {
updateLock.unlock();
}
} else {
// Contention failed, the thread will yield its time slice to wait for bucket available.
Thread.yield();
}
}
请问以上LeapArray currentWindow方法的代码是否有多线程问题, 第一个线程在resetWindowTo, resetWindowTo有两步,第一步w.resetTo(startTime); 第二步w.value().reset(); 当第一步完成时,另外一个线程正好判断windowStart == old.windowStart()通过,但是value().rest()还没有执行,拿到了没有reset的value,请教一下这里会出现这样的问题吗?
Contributor guide
Research direction
Start by tracing LeapArray.currentWindow and resetWindowTo, focusing on the ordering between w.resetTo(startTime) and w.value().reset(). Analyze the interleaving described in the issue and determine whether another thread can observe the partially reset window; completion requires a confirmed conclusion and an agreed corrective change if the race is reproducible.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100