Remove ask-based close transaction chain persistence 86/82386/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 23 May 2019 16:57:00 +0000 (18:57 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 3 Jun 2019 15:35:38 +0000 (17:35 +0200)
ask-based protocol has tracking disabled when encountered, hence
it does not make sense to persist anything.

JIRA: CONTROLLER-1628
Change-Id: I1ec87a9905aa76f3e2a57ae2440c8c693ff60848
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 8182b2647acc326e66da9f66fbe69e16435567d6)

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

index be22efaa100150d506fe9253bee60c3e3191283c..a0c3e7f5709d8f3fbc0bbcbcda7b34736ae3b881 100644 (file)
@@ -824,10 +824,7 @@ public class Shard extends RaftActor {
         if (isLeader()) {
             final LocalHistoryIdentifier id = closeTransactionChain.getIdentifier();
             askProtocolEncountered(id.getClientId());
-
-            // FIXME: CONTROLLER-1628: stage purge once no transactions are present
-            store.closeTransactionChain(id, null);
-            store.purgeTransactionChain(id, null);
+            store.closeTransactionChain(id);
         } else if (getLeader() != null) {
             getLeader().forward(closeTransactionChain, getContext());
         } else {
index c93cb50f3076d738a4135be3473a9cb6dcb00641..bb60c07ed3cb032bf40178a61882ced70f61261c 100644 (file)
@@ -591,18 +591,33 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
      * @param callback Callback to invoke upon completion, may be null
      */
     void closeTransactionChain(final LocalHistoryIdentifier id, @Nullable final Runnable callback) {
+        if (commonCloseTransactionChain(id, callback)) {
+            replicatePayload(id, CloseLocalHistoryPayload.create(id,
+                shard.getDatastoreContext().getInitialPayloadSerializedBufferCapacity()), callback);
+        }
+    }
+
+    /**
+     * Close a single transaction chain which is received through ask-based protocol. It does not keep a commit record.
+     *
+     * @param id History identifier
+     */
+    void closeTransactionChain(final LocalHistoryIdentifier id) {
+        commonCloseTransactionChain(id, null);
+    }
+
+    private boolean commonCloseTransactionChain(final LocalHistoryIdentifier id, @Nullable final Runnable callback) {
         final ShardDataTreeTransactionChain chain = transactionChains.get(id);
         if (chain == null) {
             LOG.debug("{}: Closing non-existent transaction chain {}", logContext, id);
             if (callback != null) {
                 callback.run();
             }
-            return;
+            return false;
         }
 
         chain.close();
-        replicatePayload(id, CloseLocalHistoryPayload.create(
-                id, shard.getDatastoreContext().getInitialPayloadSerializedBufferCapacity()), callback);
+        return true;
     }
 
     /**