narendly commented on a change in pull request #933: Fix MetadataStoreDirectory 
routing data cache refresh bug
URL: https://github.com/apache/helix/pull/933#discussion_r404961093
 
 

 ##########
 File path: 
helix-rest/src/main/java/org/apache/helix/rest/metadatastore/ZkMetadataStoreDirectory.java
 ##########
 @@ -322,14 +322,19 @@ public void refreshRoutingData(String namespace) {
     }
 
     Map<String, List<String>> rawRoutingData;
+    // Remove the raw data first in case of failure on creation
+    _realmToShardingKeysMap.remove(namespace);
     try {
       rawRoutingData = _routingDataReaderMap.get(namespace).getRoutingData();
       _realmToShardingKeysMap.put(namespace, rawRoutingData);
     } catch (InvalidRoutingDataException e) {
+      _routingDataMap.remove(namespace);
       LOG.error("Failed to refresh cached routing data for namespace {}", 
namespace, e);
       return;
     }
 
+    // Remove routing data first in case of failure on creation
+    _routingDataMap.remove(namespace);
 
 Review comment:
   Why don't you just put `_routingDataMap.remove(namespace);` up there next to 
`_realmToShardingKeysMap.remove(namespace);`?
   
   Why is there a need for this duplicate code? routingDataMap entry should be 
cleared anyway prior to update, right?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to