Skip to content

currentWindow concurrency problem | currentWindow 多线程issue #2949

@PatrickZhangOracle

Description

@PatrickZhangOracle

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,请教一下这里会出现这样的问题吗?

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/metricsIssues or PRs related to metrics and monitoringkind/questionCategory issues related to questions or problems

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions