Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.5.4
-
None
Description
CommitRateLimiter.delay has a race-condition when the queue length drops below thres-hold right when delay() is called. Consider the following steps:
- thread T1 enters delay() with a positive value for delay but gets paused right after the check for delay>0
- thread T2 enters setDelay(0), thus goes into the synchronized block and does a notifyAll
- thread T1 continues in delay() after above mentioned check, thus now goes into the synchronized block - at this stage delay is 0 (as it's volatile) - thus it sets dt=0.
- thread T1 then goes and calls wait(0) - which is an infinite wait, until it gets notified. This can be forever if the threshold is never ever hit again.
Would suggest to do a while loop rather than a do-while