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 --It will
terminate only case when interrupt is received when running, this is not a
normal scenario, and can happen when OM is shutdown
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]