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


##########
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:
   4 places, terminate is used,
   1. DoubleBuffer->canFlush() -- terminate on interrupt Exception -- I think 
we should not terminate as its normal pause() operation call supported. This is 
added with "HDDS-7279. Snapshot Create requires Double Buffer Flush thread to 
split the commit batch. ". Created 
[HDDS-11182](https://issues.apache.org/jira/browse/HDDS-11182) to handle same.
   
   2. DoubleBuffer->addToBatch IOException --- This is possible due to user 
implementation of Response. This will be further candidate to have readonly 
mode but `currently not in scope `of this.
   3. DoubleBuffer --> flush db fails, IMO should terminate OM as there may be 
possibility of disk error, and there can be switchover and new leader can take 
up job.
   4. OMStateMachine --> processResponse --> trigger terminate on specific 
error like metadata error or internal error. Terminate should be fine for 
metadata error (for rocksdb) so that new leader can take up job. But 
`INTERNAL_ERROR` will not be candidate for this. This part will fix.
   



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