peterxcli commented on code in PR #9319:
URL: https://github.com/apache/ozone/pull/9319#discussion_r2563280898
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerProtocolServerSideTranslatorPB.java:
##########
@@ -184,12 +184,12 @@ public OMRequest getLastRequestToSubmit() {
private OMResponse submitReadRequestToOM(OMRequest request)
throws ServiceException {
+ // Get current OM's role
+ RaftServerStatus raftServerStatus = omRatisServer.getLeaderStatus();
// Read from leader or followers using linearizable read
- if (omRatisServer.isLinearizableRead()) {
+ if (omRatisServer.isLinearizableRead() && raftServerStatus == NOT_LEADER) {
Review Comment:
I think even if the above scenario doesn’t happen, stale reads are still
possible. Since the committed index and the state machine’s apply speed are
decoupled, reading without going through Ratis can return data that hasn’t yet
been applied by the state machine.
I’m not sure how Ratis handles read requests internally, but a safe and
efficient approach would be:
1. Receive the read request.
2. Record the current committed index.
3. Wait until the state machine has applied up to that committed index.
4. Delegate the read to the state machine.
--
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]