Bug 7728 - modules-state conflict kills rest-connector-default-impl 43/52243/2
authorIvan Hrasko <ivan.hrasko@pantheon.tech>
Fri, 24 Feb 2017 11:52:11 +0000 (12:52 +0100)
committerIvan Hrasko <ivan.hrasko@pantheon.tech>
Fri, 24 Feb 2017 11:54:54 +0000 (12:54 +0100)
-improved workaround:
reset transaction chain to be able to continue writing another data
after transaction fail

Change-Id: I24d608b9a01da10ab237f3b1d9b29a6f30953e0d
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/handlers/SchemaContextHandler.java

index c5a62737ae61ac5c9d511c7bef9e9617c05fe7a1..419857303e41a14d7db1dbdb66ec3fee8838d2ad 100644 (file)
@@ -13,6 +13,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
+import org.opendaylight.restconf.RestConnectorProvider;
 import org.opendaylight.restconf.Rfc8040.IetfYangLibrary;
 import org.opendaylight.restconf.Rfc8040.MonitoringModule;
 import org.opendaylight.restconf.utils.mapping.RestconfMappingNodeUtil;
@@ -82,16 +83,20 @@ public class SchemaContextHandler implements SchemaContextListenerHandler {
         try {
             wTx.submit().checkedGet();
         } catch (final TransactionCommitFailedException e) {
-            if (e.getCause() instanceof ConflictingModificationAppliedException) {
-                /*
-                  Ignore error when another cluster node is already putting the same data to DS.
-                  This is workaround for bug:
-                  https://bugs.opendaylight.org/show_bug.cgi?id=7728
-                */
-                LOG.warn("Ignoring that another cluster node is already putting the same data to DS.", e);
-            } else {
+            if (!(e.getCause() instanceof ConflictingModificationAppliedException)) {
                 throw new RestconfDocumentedException("Problem occurred while putting data to DS.", e);
             }
+
+            /*
+              Ignore error when another cluster node is already putting the same data to DS.
+              We expect that cluster is homogeneous and that node was going to write the same data
+              (that means no retry is needed). Transaction chain reset must be invoked to be able
+              to continue writing data with another transaction after failed transaction.
+              This is workaround for bug:
+              https://bugs.opendaylight.org/show_bug.cgi?id=7728
+            */
+            LOG.warn("Ignoring that another cluster node is already putting the same data to DS.", e);
+            RestConnectorProvider.resetTransactionChainForAdapaters(this.transactionChainHandler.get());
         }
     }
 }