BUG-8639: always invalidate primary info cache 94/62994/2
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 11 Sep 2017 14:03:58 +0000 (16:03 +0200)
committerRobert Varga <nite@hq.sk>
Fri, 29 Sep 2017 10:38:57 +0000 (10:38 +0000)
When we remove local shard, make sure we invalidate the associated
cache entry.

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

opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/ModuleShardBackendResolver.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManager.java

index f0775ba289fcae321fce46132290e9f32faaa6a1..ee549d36118e8f026f1ed6e83c80b842fe5bbf50 100644 (file)
@@ -108,6 +108,9 @@ final class ModuleShardBackendResolver extends AbstractShardBackendResolver {
             if (failure != null) {
                 LOG.debug("Resolution of cookie {} shard {} failed, removing state", cookie, shardName, failure);
                 backends.remove(cookie, toInsert);
+
+                // Remove cache state in case someone else forgot to invalidate it
+                flushCache(shardName);
             }
         });
 
index 6d26b8419c3561dd070623821e62cfca116674f2..992786ad4bffaeb8cb17108def34c0ea60b67df8 100644 (file)
@@ -531,6 +531,9 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
                     }
 
                     self().tell((RunnableMessage) () -> {
+                        // At any rate, invalidate primaryShardInfo cache
+                        primaryShardInfoCache.remove(shardName);
+
                         shardActorsStopping.remove(shardName);
                         notifyOnCompleteTasks(failure, result);
                     }, ActorRef.noSender());