swaroopak commented on a change in pull request #626: PHOENIX-5531: 
IndexUpgradeTool crashes for tables without any indexes…
URL: https://github.com/apache/phoenix/pull/626#discussion_r345953445
 
 

 ##########
 File path: 
phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexUpgradeTool.java
 ##########
 @@ -321,38 +320,50 @@ public int executeTool() {
 
     private int executeTool(Connection conn, ConnectionQueryServices 
queryServices,
             Configuration conf) {
-
         LOGGER.info("Executing " + operation);
         for (Map.Entry<String, HashSet<String>> entry 
:tablesAndIndexes.entrySet()) {
             String dataTableFullName = entry.getKey();
             HashSet<String> indexes = entry.getValue();
 
             try (Admin admin = queryServices.getAdmin()) {
-
                 PTable dataTable = PhoenixRuntime.getTableNoCache(conn, 
dataTableFullName);
-                LOGGER.info("Executing " + operation + " for " + 
dataTableFullName);
+                LOGGER.info("Executing " + operation + " of " + 
dataTableFullName);
 
-                boolean mutable = !(dataTable.isImmutableRows());
-                if (!mutable) {
-                    LOGGER.info("Data table is immutable, waiting for "
+                disableTable(admin, dataTableFullName, indexes);
+                modifyTable(admin, dataTableFullName, indexes);
+                if (dataTable.isImmutableRows()) {
+                    // If the table is immutable, we need to wait for clients 
to purge
+                    // their caches of table metadata
+                    LOGGER.info(dataTableFullName + " is an immutable table, 
waiting for "
                             + (GLOBAL_INDEX_CHECKER_ENABLED_MAP_EXPIRATION_MIN 
+ 1)
                             + " minutes for client cache to expire");
-                    if (!test) {
-                        
Thread.sleep((GLOBAL_INDEX_CHECKER_ENABLED_MAP_EXPIRATION_MIN + 1)
-                                * 60 * 1000);
+                    if (!(test | dryRun)) {
+                        try {
+                            
Thread.sleep((GLOBAL_INDEX_CHECKER_ENABLED_MAP_EXPIRATION_MIN + 1)
 
 Review comment:
   or maybe not! On second thought, it seems okay. 

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to