> On May 28, 2015, 8:42 a.m., Onur Karaman wrote:
> > It seems like you're concerned about adding/removing a TimerTaskEntry that 
> > already exists in another TimerTaskList. Can you explain how that can 
> > happen? My understanding of the timing wheel stuff is only so-so.

For adding, a TimerTaskEntry should not exist in any list. If it does, removing 
it from the existing list keeps the structure consistent. That is why I added 
the remove call in the add method.
For removing, there is a race condition. When a bucket expires, an entry in the 
bucket is either expired or moved to a finer grain wheel. TimerTaskEntry.remove 
is called then. Then the race condition happens if TimerTask.cancel is called 
at the same time. The remove operation is synchronized on a TimerTaskList 
instance. Therefore, in the syncrinized block, we have to doublecheck that the 
entry still belongs to the list. If the mehod doesn't remove the entry from the 
list due to the race condition, it will retry.


- Yasuhiro


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/34734/#review85530
-----------------------------------------------------------


On May 27, 2015, 9 p.m., Yasuhiro Matsuda wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/34734/
> -----------------------------------------------------------
> 
> (Updated May 27, 2015, 9 p.m.)
> 
> 
> Review request for kafka.
> 
> 
> Bugs: KAFKA-2226
>     https://issues.apache.org/jira/browse/KAFKA-2226
> 
> 
> Repository: kafka
> 
> 
> Description
> -------
> 
> fix a race condition in TimerTaskEntry.remove
> 
> 
> Diffs
> -----
> 
>   core/src/main/scala/kafka/utils/timer/TimerTaskList.scala 
> e7a96570ddc2367583d6d5590628db7e7f6ba39b 
> 
> Diff: https://reviews.apache.org/r/34734/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Yasuhiro Matsuda
> 
>

Reply via email to