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

 ##########
 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. "
 
 Review comment:
   If we get interrupted here before we've slept our full time, shouldn't we 
take some action rather than just logging and swallowing the exception? If we 
proceed with enabling the table before the full span is done, we risk the cache 
coherency problems we were trying to fix in the first place. 

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

Reply via email to