ivandika3 opened a new pull request, #11257:
URL: https://github.com/apache/ozone/pull/11257

   ## What changes were proposed in this pull request?
   
   While working on 
[HDDS-15089](https://issues.apache.org/jira/browse/HDDS-15089), encountered an 
NPE issue that was caused by null 
   `Server.getRemoteUser()` in `OzoneManager#getS3VolumeContext`. This reason 
is that Ratis would call StateMachine#query in a separate thread (under 
`RaftServerImpl#clientExecutor`). Therefore, the `ThreadLocal` in 
`OzoneManager` and the `CurrCall` which is used by `Server.getRemoteUser()` is 
not going to be propagated.
   
   This affects most read requests submitted to Ratis (executed in 
OzoneManagerStateMachine#query) that require using ThreadLocal one way or 
another.
    
   We need a way to propagate the Server#getCurrcall ThreadLocal context to the 
StateMachine#query.
    
   *Note this suggests that follower read feature is not production ready until 
this is resolved.*
   
   The main mechanism is the introduction of `OMRatisRequestContext` which is a 
context mechanism to pass the OM ThreadLocal info OMRequest UserInfo and allows 
the `OzoneManagerStateMachine#query` (that is executed in a separate thread) to 
create am artificial `Server.Call` with `getRemoteUser` and 
`getHostInetAddress` so that `Server.getRemoteUser()` will not return null. 
Note that OM might need to use the `RaftServer#readOnlyAsync` 
(https://github.com/apache/ratis/pull/1448) that might either be executed 
directly in caller thread (if we use `DEFAULT` ReadOption) or executed in 
another thread (if we use `LINEARIZABLE` ReadOption). Therefore, 
`OMRatisRequestContext` should handle context propagation within a thread and 
across a thread.
   
   I chose this approach since it does not need to change every OM read 
implementation. However, any suggestions to improve this design is welcome.
   
   This patch also includes some refactoring on `OMLockDetailsUtil` and 
`S3AuthenticationContext` to reduce duplications.
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-16497
   
   ## How was this patch tested?
   
   UT.


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to