errose28 commented on code in PR #6928:
URL: https://github.com/apache/ozone/pull/6928#discussion_r1674611595


##########
hadoop-hdds/common/src/main/resources/ozone-default.xml:
##########
@@ -4415,4 +4415,12 @@
       maximum number of buckets across all volumes.
     </description>
   </property>
+  <property>
+    <name>ozone.om.onfailure.readonly.enable</name>

Review Comment:
   Maybe `ozone.om.readonly.on.failure` would be more intuitive?



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerStateMachine.java:
##########
@@ -551,6 +579,24 @@ private OMResponse runCommand(OMRequest request, TermIndex 
termIndex) {
       return createErrorResponse(request, e, termIndex);
     } catch (Throwable e) {
       // For any Runtime exceptions, terminate OM.
+      final boolean onFailureReadonlyEnable = ozoneManager.getConfiguration()
+          .getBoolean(OMConfigKeys.OZONE_OM_ONFAILURE_READONLY,
+              OMConfigKeys.OZONE_OM_ONFAILURE_READONLY_DEFAULT);
+      if (onFailureReadonlyEnable) {
+        LOG.error("Failed to write, moving to readonly mode, Exception 
occurred ", e);
+        if (readonlyMode.compareAndSet(false, true)) {
+          // update readonly mode, flush existing transaction and pause state 
machine
+          readonlyMode.set(true);
+          try {
+            awaitDoubleBufferFlush();
+          } catch (InterruptedException ex) {
+            Thread.interrupted();
+          }
+          pause();
+        }
+        return createErrorResponse(request, new OMException("Exception 
occurred and moving to readonly mode",
+            e, OMException.ResultCodes.READONLY_MODE), termIndex);
+      }
       String errorMessage = "Request " + request + " failed with exception";
       ExitUtils.terminate(1, errorMessage, e, LOG);

Review Comment:
   There's actually multiple termination points in this class. I haven't looked 
through it in detail but we want to make sure we are going to readonly only 
when there is an exception processing the `validateAndUpdateCache` method. I'm 
not sure if we should remain in readonly mode if there is an error writing to 
the DB or continue to terminate in this case.



##########
hadoop-hdds/common/src/main/resources/ozone-default.xml:
##########
@@ -4415,4 +4415,12 @@
       maximum number of buckets across all volumes.
     </description>
   </property>
+  <property>
+    <name>ozone.om.onfailure.readonly.enable</name>
+    <value>false</value>
+    <tag>OZONE, OM</tag>
+    <description>
+      enable readonly mode when om state machine failure is observed.

Review Comment:
   ```suggestion
   Put the Ozone Manager in readonly mode instead of shutting down when there 
is a fatal error while handling a write request.
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerStateMachine.java:
##########
@@ -551,6 +579,24 @@ private OMResponse runCommand(OMRequest request, TermIndex 
termIndex) {
       return createErrorResponse(request, e, termIndex);
     } catch (Throwable e) {
       // For any Runtime exceptions, terminate OM.

Review Comment:
   This comment needs to be updated.



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerStateMachine.java:
##########
@@ -254,6 +257,17 @@ public void 
notifySnapshotInstalled(RaftProtos.InstallSnapshotResult result,
   @Override
   public TransactionContext startTransaction(
       RaftClientRequest raftClientRequest) throws IOException {
+    if (readonlyMode.get()) {
+      TransactionContext ctxt = TransactionContext.newBuilder()
+          .setClientRequest(raftClientRequest)
+          .setStateMachine(this)
+          .setServerRole(RaftProtos.RaftPeerRole.LEADER)
+          .build();
+      ctxt.setException(new OMException("OM is running in readonly mode",

Review Comment:
   This should specify that it is in this state due to an internal error. 
Otherwise it is not clear how the OM got into this state.



##########
hadoop-hdds/common/src/main/resources/ozone-default.xml:
##########
@@ -4415,4 +4415,12 @@
       maximum number of buckets across all volumes.
     </description>
   </property>
+  <property>
+    <name>ozone.om.onfailure.readonly.enable</name>
+    <value>false</value>

Review Comment:
   Why not default to true?



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerStateMachine.java:
##########
@@ -287,6 +301,11 @@ public TransactionContext 
preAppendTransaction(TransactionContext trx)
     final OMRequest request = (OMRequest) trx.getStateMachineContext();
     OzoneManagerProtocolProtos.Type cmdType = request.getCmdType();
 
+    if (readonlyMode.get()) {

Review Comment:
   Why are we checking this in so many places? Prepare does a similar thing 
with just a pre-append check, since all write requests must go through there. I 
actually don't recall the difference between preAppend and startTransaction to 
know which is better for the use case in this change.



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