[ 
https://issues.apache.org/jira/browse/KAFKA-18877?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17930871#comment-17930871
 ] 

David Arthur commented on KAFKA-18877:
--------------------------------------

I think the most likely unsafe access is reading from a control manager from 
the request thread (like in the referenced PR). In some cases, it is safe to 
access a control manager's state from outside the controller thread (like in 
processBrokerHeartbeat), but in most cases it isn't. It would be great if we 
could easily differentiate safe vs unsafe access in the control managers. 

 

Maybe we could split the control managers classes into two interfaces 
(controller-thread-only and any-thread) so we could use the type system to 
ensure safe access. 

 

Another idea is to do some runtime check from inside the control managers 
themselves. "if (current thread != controller) panic"

 

> an mechanism to find cases where we accessed variables from the wrong thread
> ----------------------------------------------------------------------------
>
>                 Key: KAFKA-18877
>                 URL: https://issues.apache.org/jira/browse/KAFKA-18877
>             Project: Kafka
>          Issue Type: Improvement
>            Reporter: Chia-Ping Tsai
>            Assignee: Chia-Ping Tsai
>            Priority: Major
>
> from [https://github.com/apache/kafka/pull/18997#pullrequestreview-2645589959]
> There are some _non-thread safe_ classes storing the important information, 
> and so they are expected to be access by specific thread.  Otherwise, it may 
> cause unexpected behavior



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to