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

 ##########
 File path: 
metadata-store-directory-common/src/main/java/org/apache/helix/msdcommon/datamodel/TrieRoutingData.java
 ##########
 @@ -48,6 +48,10 @@ public TrieRoutingData(Map<String, List<String>> 
routingData)
       throw new InvalidRoutingDataException("routingData cannot be null or 
empty");
     }
 
+    if (!containsShardingKey(routingData)) {
+      throw new InvalidRoutingDataException("routingData needs at least 1 
sharding key");
+    }
 
 Review comment:
   We agreed that it's okay for some realms to not have keys (which is handled 
correctly by skipping them), but not when **all** realms have no keys. The 
design of `TrieRoutingData` is "a set of data with routing capability", 
therefore empty routing data shouldn't be created; a group of realms with 0 key 
doesn't have routing capability either. When the `TrieRoutingData` doesn't have 
routing capability, we don't create it. 
   In the situation with 0 sharding keys but some realms, the current 
`TrieRoutingData` will create a structure in an erroneous state. The promise of 
`TrieRoutingData` is to contain at least 1 sharding key; with 0 sharding keys, 
some functionality will break. For example, `isShardingKeyInsertionValid("/")` 
called on a `TrieRoutingData` with 0 sharding key will return false, even 
though it should be true. 

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