ashish-kumar-sharma commented on a change in pull request #1610:
URL: https://github.com/apache/hive/pull/1610#discussion_r574408036



##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/SharedCache.java
##########
@@ -2187,7 +2139,7 @@ public void addPrimaryKeysToCache(String catName, String 
dbName, String tblName,
       cacheLock.readLock().lock();
       String tblKey = CacheUtils.buildTableKey(catName, dbName, tblName);
       TableWrapper tblWrapper = tableCache.getIfPresent(tblKey);
-      if (tblWrapper != null) {
+      if (tblWrapper != null && tblWrapper.isConstraintsValid()) {

Review comment:
       Q Why do we update cache for each constraint individually? 
   
   Ans - To update the cache for specific constraint for query like "ALTER 
TABLE table_name ADD CONSTRAINT" instead of invalidating the whole cache and 
updating again because that will lead to cache miss or extra network call is 
required to delete and update all cache constraints.
   
   Q We should always cache a single snapshot of constraints of table. If not, 
isConstraintsValid flag wouldn't make sense.
   
   Ans - So if isConstraintsValid is valid that means there is valid copy of 
constraint present then we can add the incoming constraint and save redundant 
call. if isConstraintsValid is false then skip because cached constraint are 
inaccessible and waiting for refreshed




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



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

Reply via email to