Bug 509: Improve conflict detection of leaf merges 22/7022/1
authorRobert Varga <rovarga@cisco.com>
Thu, 15 May 2014 14:55:02 +0000 (16:55 +0200)
committerRobert Varga <rovarga@cisco.com>
Thu, 15 May 2014 15:27:08 +0000 (17:27 +0200)
Original conflict detection for merge action on leaves
only looked at node version and subtree version, which
caused the transaction to fail even if the leaf was
unmodified and contained the same value.

Conflict detection now checks if the leaves are not same,
and only in that case it checks for concurrent writes.

Change-Id: I5e43233e86adf96e3dad2a93cdcf512b3d17977a
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaAwareApplyOperation.java

index 2af522ea861791fcae324f2f5761b258d93b8845..afe9653394ec4a3363d34a48d9cd937b73363de1 100644 (file)
@@ -166,7 +166,16 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper
     protected void checkMergeApplicable(final InstanceIdentifier path,final NodeModification modification, final Optional<StoreMetadataNode> current) throws DataPreconditionFailedException {
         Optional<StoreMetadataNode> original = modification.getOriginal();
         if (original.isPresent() && current.isPresent()) {
-            checkNotConflicting(path,original.get(), current.get());
+            /*
+             * We need to do conflict detection only and only if the value of leaf changed
+             * before two transactions. If value of leaf is unchanged between two transactions
+             * it should not cause transaction to fail, since result of this merge
+             * leads to same data.
+             */
+            if(!original.get().getData().equals(current.get().getData())) {
+
+                checkNotConflicting(path,original.get(), current.get());
+            }
         }
     }