BUG-5280: make sure we have metadata for standalone history 88/54088/3
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 30 Mar 2017 08:45:50 +0000 (10:45 +0200)
committerTom Pantelis <tompantelis@gmail.com>
Fri, 31 Mar 2017 10:58:54 +0000 (10:58 +0000)
With metadata propagation in place, we get a ton of warnings
in the form of:

Unknown history for aborted transaction member-2-datastore-config-fe-0-txn-1261-0, ignoring

which is indicative of our failure to populate metadata builder
with the history for standalone transactions. This patch fixes
that and adds recovery for the case when we fail to find the
history in recovered journal.

Change-Id: I338666dbd910ec683a44a814deed7382eb255218
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendClientMetadataBuilder.java

index 8a0ce60..ec2cdb6 100644 (file)
@@ -39,6 +39,10 @@ final class FrontendClientMetadataBuilder implements Builder<FrontendClientMetad
     FrontendClientMetadataBuilder(final ClientIdentifier identifier) {
         this.identifier = Preconditions.checkNotNull(identifier);
         purgedHistories = TreeRangeSet.create();
+
+        // History for stand-alone transactions is always present
+        final LocalHistoryIdentifier standaloneId = standaloneHistoryId();
+        currentHistories.put(standaloneId, new FrontendHistoryMetadataBuilder(standaloneId));
     }
 
     FrontendClientMetadataBuilder(final FrontendClientMetadata meta) {
@@ -49,6 +53,18 @@ final class FrontendClientMetadataBuilder implements Builder<FrontendClientMetad
             final FrontendHistoryMetadataBuilder b = new FrontendHistoryMetadataBuilder(identifier, h);
             currentHistories.put(b.getIdentifier(), b);
         }
+
+        // Sanity check and recovery
+        final LocalHistoryIdentifier standaloneId = standaloneHistoryId();
+        if (!currentHistories.containsKey(standaloneId)) {
+            LOG.warn("Client {} recovered histories {} do not contain stand-alone history, attempting recovery",
+                identifier, currentHistories);
+            currentHistories.put(standaloneId, new FrontendHistoryMetadataBuilder(standaloneId));
+        }
+    }
+
+    private LocalHistoryIdentifier standaloneHistoryId() {
+        return new LocalHistoryIdentifier(identifier, 0);
     }
 
     @Override

©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.