stoty commented on code in PR #1927:
URL: https://github.com/apache/phoenix/pull/1927#discussion_r1689290436


##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/LoadSystemTableSnapshotBase.java:
##########
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.end2end;

Review Comment:
   This is not good inheritance.
   The base class should be abstract, and only containthe helper methods.
   
   The child classes should not be named LoadSystemTable...



##########
phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java:
##########
@@ -5052,6 +5070,39 @@ void ensureSystemTablesMigratedToSystemNamespace()
         }
     }
 
+    /**
+     * Acquire distributed mutex of sorts to make sure only one JVM is able to 
run the upgrade code by
+     * making use of HBase's checkAndPut api.
+     *
+     * @return true if client won the race, false otherwise
+     * @throws SQLException
+     */
+    @VisibleForTesting
+    public boolean acquireUpgradeBlockMutex()
+            throws SQLException {
+        try (Table sysMutexTable = getSysMutexTable()) {
+            final byte[] rowKey = Bytes.toBytes("BLOCK_UPGRADE");

Review Comment:
   Do we need to do a checkAndPut ?
   
   If we assume that the block is created and removed manually, then a simple 
read would suffice.
   We already have a separate mechanism to make sure that only a single JVM is 
running the upgrade.



##########
phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java:
##########
@@ -5052,6 +5070,39 @@ void ensureSystemTablesMigratedToSystemNamespace()
         }
     }
 
+    /**
+     * Acquire distributed mutex of sorts to make sure only one JVM is able to 
run the upgrade code by

Review Comment:
   That's not really what this mutex does.
   The single JVM problem is handled by acquireUpgradeMutex().
   
   This one is just blocking all clients which have not explicitly overriden 
this.



##########
phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java:
##########
@@ -4498,6 +4509,13 @@ public void upgradeSystemTables(final String url, final 
Properties props) throws
                         "Snapshots for system tables created so far: {}",
                         systemTableToSnapshotMap);
                 }
+                if (acquiredBlockMutexLock) {
+                    try {
+                        releaseUpgradeBlockMutex();

Review Comment:
   I'm not sure we want to release this mutex automatically.
   
   This block was created manually, and the upgrade may have failed, which we 
have no easy way of checking from code.
   
   



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

Reply via email to