You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by GitBox <gi...@apache.org> on 2019/12/20 19:40:51 UTC

[GitHub] [phoenix] gokceni commented on a change in pull request #660: PHOENIX-5644: IndexUpgradeTool should sleep only once if there is at …

gokceni commented on a change in pull request #660: PHOENIX-5644: IndexUpgradeTool should sleep only once if there is at …
URL: https://github.com/apache/phoenix/pull/660#discussion_r360542820
 
 

 ##########
 File path: phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexUpgradeTool.java
 ##########
 @@ -367,6 +358,53 @@ private int executeTool(Connection conn, ConnectionQueryServices queryServices,
         return 0;
     }
 
+    private void executeToolForImmutableTables(ConnectionQueryServices queryServices,
+            ArrayList<String> immutableList) {
+
+        boolean atLeastOneHasIndexes=false;
+
+        for (String dataTableFullName : immutableList) {
+            HashSet<String> indexes = tablesAndIndexes.get(dataTableFullName);
+            if (!(indexes.isEmpty() || atLeastOneHasIndexes)) {
+                atLeastOneHasIndexes = true;
+            }
+            try (Admin admin = queryServices.getAdmin()) {
+                LOGGER.info("Executing " + operation + " of " + dataTableFullName
+                        + " (immutable)");
+                disableTable(admin, dataTableFullName, indexes);
+                modifyTable(admin, dataTableFullName, indexes);
+            } catch (IOException | SQLException e) {
+                LOGGER.severe("Something went wrong while disabling or modifying immutable "
+                        + "table " + dataTableFullName+ " " + e);
+            }
+        }
+        // If the table is immutable, we need to wait for clients to purge
+        // their caches of table metadata
+        if (!(test || dryRun) && atLeastOneHasIndexes) {
+            LOGGER.info("The input list has at least one immutable table with indexes, "
+                    + "waiting for " + (GLOBAL_INDEX_CHECKER_ENABLED_MAP_EXPIRATION_MIN + 1)
+                    + " minutes for client cache to expire");
+            try {
+                Thread.sleep((GLOBAL_INDEX_CHECKER_ENABLED_MAP_EXPIRATION_MIN + 1)
+                        * 60 * 1000);
+            } catch (InterruptedException e) {
+                LOGGER.warning("Sleep before starting index rebuild is interrupted. "
+                        + e.getMessage());
+            }
+        }
+        for (String dataTableFullName : immutableList) {
+            try (Admin admin = queryServices.getAdmin()) {
+                HashSet<String> indexes = tablesAndIndexes.get(dataTableFullName);
+                enableTable(admin, dataTableFullName, indexes);
+            } catch (IOException | SQLException e) {
+                LOGGER.severe("Something went wrong while enabling immutable table "
+                        + dataTableFullName + " " + e);
+            }
+            LOGGER.info("Completed " + operation + " of " + dataTableFullName
+                    + " (immutable)");
+        }
+    }
 
 Review comment:
   Consider adding tests with less sleep time than 11 mins

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


With regards,
Apache Git Services