Fix read-only abort message mismatch 74/57374/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 26 Apr 2017 12:39:23 +0000 (14:39 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 18 May 2017 15:26:44 +0000 (17:26 +0200)
Testing has revealed:

WARN  | FrontendReadOnlyTransaction | Rejecting unsupported request ModifyTransactionRequest{target=member-2-datastore-config-fe-0-txn-2-0, sequence=1, replyTo=Actor[akka.tcp://opendaylight-cluster-data@10.29.15.184:2550/user/$a#585956314], operations=[], protocol=ABORT}

This is a thinko on the part of which message does what:

TransactionAbortRequest is dedicated for 3PC doAbort phase, hence
it is never seen for read-only transactions.

The message corresponding to an abort is either
AbortLocalTransactionRequest or ModifyTransactionRequest with protocol
set to ABORT.

Change-Id: I3238ade7b9f7933e6538742354888d182f599412
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit da06e5075869af81d46b861691f2e95d22a96bbc)

opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendReadOnlyTransaction.java

index 071fded..e5680c5 100644 (file)
@@ -13,10 +13,11 @@ import javax.annotation.Nullable;
 import javax.annotation.concurrent.NotThreadSafe;
 import org.opendaylight.controller.cluster.access.commands.ExistsTransactionRequest;
 import org.opendaylight.controller.cluster.access.commands.ExistsTransactionSuccess;
+import org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest;
+import org.opendaylight.controller.cluster.access.commands.ModifyTransactionSuccess;
+import org.opendaylight.controller.cluster.access.commands.PersistenceProtocol;
 import org.opendaylight.controller.cluster.access.commands.ReadTransactionRequest;
 import org.opendaylight.controller.cluster.access.commands.ReadTransactionSuccess;
-import org.opendaylight.controller.cluster.access.commands.TransactionAbortRequest;
-import org.opendaylight.controller.cluster.access.commands.TransactionAbortSuccess;
 import org.opendaylight.controller.cluster.access.commands.TransactionRequest;
 import org.opendaylight.controller.cluster.access.commands.TransactionSuccess;
 import org.opendaylight.controller.cluster.access.concepts.RequestEnvelope;
@@ -56,8 +57,8 @@ final class FrontendReadOnlyTransaction extends FrontendTransaction {
             return handleExistsTransaction((ExistsTransactionRequest) request);
         } else if (request instanceof ReadTransactionRequest) {
             return handleReadTransaction((ReadTransactionRequest) request);
-        } else if (request instanceof TransactionAbortRequest) {
-            handleTransactionAbort((TransactionAbortRequest) request, envelope, now);
+        } else if (request instanceof ModifyTransactionRequest) {
+            handleModifyTransaction((ModifyTransactionRequest) request, envelope, now);
             return null;
         } else {
             LOG.warn("Rejecting unsupported request {}", request);
@@ -65,10 +66,15 @@ final class FrontendReadOnlyTransaction extends FrontendTransaction {
         }
     }
 
-    private void handleTransactionAbort(final TransactionAbortRequest request, final RequestEnvelope envelope,
-            final long now) throws RequestException {
-        openTransaction.abort(() -> recordAndSendSuccess(envelope, now, new TransactionAbortSuccess(request.getTarget(),
-            request.getSequence())));
+    private void handleModifyTransaction(final ModifyTransactionRequest request, final RequestEnvelope envelope,
+            final long now) {
+        // The only valid request here is with abort protocol
+        final java.util.Optional<PersistenceProtocol> optProto = request.getPersistenceProtocol();
+        Preconditions.checkArgument(optProto.isPresent(), "Commit protocol is missing in %s", request);
+        Preconditions.checkArgument(optProto.get() == PersistenceProtocol.ABORT, "Unsupported commit protocol in %s",
+                request);
+        openTransaction.abort(() -> recordAndSendSuccess(envelope, now,
+            new ModifyTransactionSuccess(request.getTarget(), request.getSequence())));
     }
 
     private ExistsTransactionSuccess handleExistsTransaction(final ExistsTransactionRequest request)

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.