kokila-19 commented on code in PR #5567:
URL: https://github.com/apache/hive/pull/5567#discussion_r1868085691


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java:
##########
@@ -10296,38 +10297,57 @@ public Map<String, String> 
updateTableColumnStatistics(ColumnStatistics colStats
       }
 
       // TODO: (HIVE-20109) ideally the col stats stats should be in colstats, 
not in the table!
-      // Set the table properties
-      // No need to check again if it exists.
-      String dbname = table.getDbName();
-      String name = table.getTableName();
-      MTable oldt = mTable;
       Map<String, String> newParams = new HashMap<>(table.getParameters());
-      StatsSetupConst.setColumnStatsState(newParams, colNames);
-      boolean isTxn = TxnUtils.isTransactionalTable(oldt.getParameters());
-      if (isTxn) {
-        if (!areTxnStatsSupported) {
-          StatsSetupConst.setBasicStatsState(newParams, StatsSetupConst.FALSE);
-        } else {
-          String errorMsg = verifyStatsChangeCtx(TableName.getDbTable(dbname, 
name),
-            oldt.getParameters(), newParams, writeId, validWriteIds, true);
+
+      int retries = 3;
+      boolean success = false;
+      while (!success && retries > 0) {
+        // TODO## ideally the col stats stats should be in colstats, not in 
the table!
+        // Set the table properties
+        // No need to check again if it exists.
+        String dbname = table.getDbName();
+        String tableName = table.getTableName();
+        StatsSetupConst.setColumnStatsState(newParams, colNames);
+        boolean isTxn = TxnUtils.isTransactionalTable(mTable.getParameters());
+        if (isTxn) {
+          if (!areTxnStatsSupported) {
+            StatsSetupConst.setBasicStatsState(newParams, 
StatsSetupConst.FALSE);
+          } else {
+            String errorMsg = 
verifyStatsChangeCtx(TableName.getDbTable(dbname, tableName),
+            mTable.getParameters(), newParams, writeId, validWriteIds, true);
           if (errorMsg != null) {
             throw new MetaException(errorMsg);
           }
-          if (!isCurrentStatsValidForTheQuery(oldt, validWriteIds, true)) {
+          if (!isCurrentStatsValidForTheQuery(mTable, validWriteIds, true)) {
             // Make sure we set the flag to invalid regardless of the current 
value.
             StatsSetupConst.setBasicStatsState(newParams, 
StatsSetupConst.FALSE);
             LOG.info("Removed COLUMN_STATS_ACCURATE from the parameters of the 
table "
-              + dbname + "." + name);
+              + dbname + "." + tableName);
           }
-          oldt.setWriteId(writeId);
+          mTable.setWriteId(writeId);
+        }
+      }
+        try {
+          mTable.setParameters(newParams);
+          success = true;
+        }
+        catch (NucleusDataStoreException e) {
+          retries--;
+
+          if (retries == 0) {

Review Comment:
   How about logging the error here? Something like Maximum number of retries 
(Retry = 3) reached.



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

To unsubscribe, e-mail: [email protected]

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