phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject phoenix git commit: PHOENIX-2713 Backward compatibility fails with CNF exception with 4.7 client and server when upgraded from 4.6
Date Wed, 24 Feb 2016 20:08:35 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.0 8f1eb83b0 -> 76f17a5aa


PHOENIX-2713 Backward compatibility fails with CNF exception with 4.7 client and server when
upgraded from 4.6


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/76f17a5a
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/76f17a5a
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/76f17a5a

Branch: refs/heads/4.x-HBase-1.0
Commit: 76f17a5aa4b393770079d7d334c762b4c7841f59
Parents: 8f1eb83
Author: James Taylor <jtaylor@salesforce.com>
Authored: Wed Feb 24 11:48:16 2016 -0800
Committer: James Taylor <jtaylor@salesforce.com>
Committed: Wed Feb 24 12:08:24 2016 -0800

----------------------------------------------------------------------
 .../phoenix/coprocessor/MetaDataProtocol.java   |  2 +-
 .../query/ConnectionQueryServicesImpl.java      | 35 ++++++++++++++++----
 2 files changed, 30 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/76f17a5a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
index a704e22..fb9d228 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
@@ -73,7 +73,7 @@ public abstract class MetaDataProtocol extends MetaDataService {
     public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_3_0 = MIN_TABLE_TIMESTAMP + 7;
     public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_5_0 = MIN_TABLE_TIMESTAMP + 8;
     public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_6_0 = MIN_TABLE_TIMESTAMP + 9;
-    public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0 = MIN_TABLE_TIMESTAMP + 13;
+    public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0 = MIN_TABLE_TIMESTAMP + 14;
     // MIN_SYSTEM_TABLE_TIMESTAMP needs to be set to the max of all the MIN_SYSTEM_TABLE_TIMESTAMP_*
constants
     public static final long MIN_SYSTEM_TABLE_TIMESTAMP = MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0;
     // TODO: pare this down to minimum, as we don't need duplicates for both table and column
errors, nor should we need

http://git-wip-us.apache.org/repos/asf/phoenix/blob/76f17a5a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index 4c48179..1c2e26a 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -2366,17 +2366,20 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices
implement
                                     // Add these columns one at a time, each with different
timestamps so that if folks have
                                     // run the upgrade code already for a snapshot, we'll
still enter this block (and do the
                                     // parts we haven't yet done).
-                                    metaConnection = addColumnsIfNotExists(metaConnection,
PhoenixDatabaseMetaData.SYSTEM_CATALOG, MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0
- 2,
+                                    metaConnection = addColumnsIfNotExists(metaConnection,
PhoenixDatabaseMetaData.SYSTEM_CATALOG, MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0
- 4,
                                             PhoenixDatabaseMetaData.TRANSACTIONAL + " " +
PBoolean.INSTANCE.getSqlTypeName());
                                     // Drop old stats table so that new stats table is created
                                     metaConnection = dropStatsTable(metaConnection,
-                                            MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0
- 1);
+                                            MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0
- 3);
                                     metaConnection = addColumnsIfNotExists(metaConnection,
                                             PhoenixDatabaseMetaData.SYSTEM_CATALOG,
-                                            MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0,
+                                            MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0
- 2,
                                             PhoenixDatabaseMetaData.UPDATE_CACHE_FREQUENCY
+ " "
                                                     + PLong.INSTANCE.getSqlTypeName());
-                                    setImmutableTableIndexesImmutable(metaConnection);
+                                    metaConnection = setImmutableTableIndexesImmutable(metaConnection,
MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0 - 1);
+                                    Properties props = PropertiesUtil.deepCopy(metaConnection.getClientInfo());
+                                    props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB,
Long.toString(MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0));
+                                    metaConnection = new PhoenixConnection(metaConnection,
ConnectionQueryServicesImpl.this, props);
                                     // that already have cached data.
 									clearCache();
                                 }
@@ -2499,7 +2502,11 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices
implement
      * @param metaConnection connection over which to run the upgrade
      * @throws SQLException
      */
-    private static void setImmutableTableIndexesImmutable(PhoenixConnection metaConnection)
throws SQLException {
+    private PhoenixConnection setImmutableTableIndexesImmutable(PhoenixConnection oldMetaConnection,
long timestamp) throws SQLException {
+        SQLException sqlE = null;
+        Properties props = PropertiesUtil.deepCopy(oldMetaConnection.getClientInfo());
+        props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(timestamp));
+        PhoenixConnection metaConnection = new PhoenixConnection(oldMetaConnection, this,
props);
         boolean autoCommit = metaConnection.getAutoCommit();
         try {
             metaConnection.setAutoCommit(true);
@@ -2516,9 +2523,25 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices
implement
                     "WHERE A.COLUMN_FAMILY IS NULL AND\n" + 
                     " B.COLUMN_FAMILY IS NOT NULL AND\n" + 
                     " A.IMMUTABLE_ROWS = TRUE");
+        } catch (SQLException e) {
+            logger.warn("exception during upgrading stats table:" + e);
+            sqlE = e;
         } finally {
-            metaConnection.setAutoCommit(autoCommit);
+            try {
+                metaConnection.setAutoCommit(autoCommit);
+                oldMetaConnection.close();
+            } catch (SQLException e) {
+                if (sqlE != null) {
+                    sqlE.setNextException(e);
+                } else {
+                    sqlE = e;
+                }
+            }
+            if (sqlE != null) {
+                throw sqlE;
+            }
         }
+        return metaConnection;
     }
 
     private PhoenixConnection dropStatsTable(PhoenixConnection oldMetaConnection, long timestamp)


Mime
View raw message