You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/06/14 07:51:00 UTC

[GitHub] [kafka] iakunin commented on pull request #10775: KAFKA-12668: Making MockScheduler.schedule safe to use in concurrent code

iakunin commented on pull request #10775:
URL: https://github.com/apache/kafka/pull/10775#issuecomment-860042763


   @mdedetrich, many thanks for your feedback!
   
   `MockScheduler` has no any background threads to deal with. It executes all the tasks in the main thread. 
   
   As far as we all know java/scala `syncronyzed` blocks are reentrant. This violates Log's assumption since Log calls schedule while holding a lock. That's the main reason of inconsistent behavior reported in [jira-issue](https://issues.apache.org/jira/browse/KAFKA-12668).
   
   For now I see only two possible solutions:
   1. Analyze the task passed to MockScheduler: if it contains any synchronization primitives. If it doesn't then it could be executed right away. Otherwise, its execution should be suspended until the lock is released. In my opinion, this solution is too complicated. Also I'm not sure if it possible at all.
   2. Much simpler solution I've implemented in this pull-request.
   
   Maybe you could give me a hint to a better solution. Thanks in advance!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org