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

Ivan Andika commented on RATIS-2712:
------------------------------------

> The Hadoop RPC ThreadLocal should be valid only at the Hadoop RPC layer. It 
> should not force other components supporting it. For example, Hadoop RPC 
> internally use ThreadLocal to store a RemoteUser. When the thread receives 
> the RPC call, it should get the RemoteUser (and clean the ThreadLocal). Then, 
> pass it to another component (say Ratis), which can use any thread model 
> processing it.

Thanks for the discussion. My thought is that ThreadLocal context propagation 
is more implicit / transparent to the implementation of StateMachine#query 
without requiring explicitly passing the ThreadLocal variable to a context 
object or in a method. I haven't really worked out the inner details, but it's 
either we make the StateMachine implementation to allow registration for 
ThreadLocal variables that can be passed in a specific point of Ratis when 
there are thread change or we somehow copy the internal ThreadLocalMap for 
every thread change.

However, I understand that it might not be appropriate for Ratis just to change 
to only support specific Hadoop RPC ThreadLocal.

> Hadoop RPC internally use ThreadLocal to store a RemoteUser. When the thread 
> receives the RPC call, it should get the RemoteUser (and clean the 
> ThreadLocal). Then, pass it to another component (say Ratis), which can use 
> any thread model processing it.

Yes, currently that is the approach done in HDDS-16497. 

> Support ThreadLocal propagation for Ratis
> -----------------------------------------
>
>                 Key: RATIS-2712
>                 URL: https://issues.apache.org/jira/browse/RATIS-2712
>             Project: Ratis
>          Issue Type: New Feature
>            Reporter: Ivan Andika
>            Assignee: Ivan Andika
>            Priority: Major
>
> See the issue in https://issues.apache.org/jira/browse/HDDS-16497 .
> Since the StateMachine#applyTransactions and StateMachine#query are executed 
> in another threads, ThreadLocal mechanisms (like in Hadoop RPC) will not work 
> (or requires workaround). 
> We can discuss whether we should support ThreadLocal propagation as a first 
> class feature of Ratis. This can be similar to 
> [https://github.com/alibaba/transmittable-thread-local]
>  



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

Reply via email to