phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an...@apache.org
Subject phoenix git commit: PHOENIX-2671 System.STATS table getting truncated every time on new client connection(Ankit Singhal)
Date Mon, 15 Feb 2016 06:33:06 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.0 6a6b64b23 -> 19012c026


PHOENIX-2671 System.STATS table getting truncated every time on new client connection(Ankit
Singhal)


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

Branch: refs/heads/4.x-HBase-1.0
Commit: 19012c0265d37cd0ae7655648810b275659b8d6e
Parents: 6a6b64b
Author: Ankit Singhal <ankitsinghal59@gmail.com>
Authored: Mon Feb 15 12:03:21 2016 +0530
Committer: Ankit Singhal <ankitsinghal59@gmail.com>
Committed: Mon Feb 15 12:03:21 2016 +0530

----------------------------------------------------------------------
 .../query/ConnectionQueryServicesImpl.java      | 48 ++++++--------------
 .../org/apache/phoenix/util/UpgradeUtil.java    | 16 +++----
 2 files changed, 22 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/19012c02/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 a8d0b39..26d7a3d 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
@@ -188,11 +188,6 @@ import org.apache.twill.zookeeper.ZKClients;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import co.cask.tephra.TransactionSystemClient;
-import co.cask.tephra.TxConstants;
-import co.cask.tephra.distributed.PooledClientProvider;
-import co.cask.tephra.distributed.TransactionServiceClient;
-
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Joiner;
 import com.google.common.base.Throwables;
@@ -254,6 +249,11 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices
implement
     private ScheduledExecutorService renewLeaseExecutor;
     private final boolean renewLeaseEnabled;
 
+import co.cask.tephra.TransactionSystemClient;
+import co.cask.tephra.TxConstants;
+import co.cask.tephra.distributed.PooledClientProvider;
+import co.cask.tephra.distributed.TransactionServiceClient;
+
 
     private static interface FeatureSupported {
         boolean isSupported(ConnectionQueryServices services);
@@ -2364,14 +2364,16 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices
implement
                                     // parts we haven't yet done).
                                     metaConnection = addColumnsIfNotExists(metaConnection,
PhoenixDatabaseMetaData.SYSTEM_CATALOG, MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0
- 2,
                                             PhoenixDatabaseMetaData.TRANSACTIONAL + " " +
PBoolean.INSTANCE.getSqlTypeName());
-                                    metaConnection = addColumnsIfNotExists(metaConnection,
PhoenixDatabaseMetaData.SYSTEM_CATALOG, MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0
- 1, 
-                                            PhoenixDatabaseMetaData.UPDATE_CACHE_FREQUENCY
+ " " + PLong.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);
+                                    metaConnection = addColumnsIfNotExists(metaConnection,
+                                            PhoenixDatabaseMetaData.SYSTEM_CATALOG,
+                                            MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0,
+                                            PhoenixDatabaseMetaData.UPDATE_CACHE_FREQUENCY
+ " "
+                                                    + PLong.INSTANCE.getSqlTypeName());
                                     setImmutableTableIndexesImmutable(metaConnection);
-									// Drop old stats table so that new stats table is created
-									metaConnection = dropStatsTable(metaConnection,
-											MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0);
-									// Clear the server cache so the above changes make it over to any clients
-									// that already have cached data.
+                                    // that already have cached data.
 									clearCache();
                                 }
                                 
@@ -2518,7 +2520,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices
implement
     private PhoenixConnection dropStatsTable(PhoenixConnection oldMetaConnection, long timestamp)
 			throws SQLException, IOException {
 		Properties props = PropertiesUtil.deepCopy(oldMetaConnection.getClientInfo());
-		props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(timestamp-1));
+		props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(timestamp));
 		PhoenixConnection metaConnection = new PhoenixConnection(oldMetaConnection, this, props);
 		SQLException sqlE = null;
 		boolean wasCommit = metaConnection.getAutoCommit();
@@ -2547,26 +2549,6 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices
implement
 				throw sqlE;
 			}
 		}
-
-		oldMetaConnection = metaConnection;
-		props = PropertiesUtil.deepCopy(oldMetaConnection.getClientInfo());
-		props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(timestamp));
-		try {
-			metaConnection = new PhoenixConnection(oldMetaConnection, ConnectionQueryServicesImpl.this,
props);
-		} finally {
-			try {
-				oldMetaConnection.close();
-			} catch (SQLException e) {
-				if (sqlE != null) {
-					sqlE.setNextException(e);
-				} else {
-					sqlE = e;
-				}
-			}
-			if (sqlE != null) {
-				throw sqlE;
-			}
-		}
 		return metaConnection;
 	}
     

http://git-wip-us.apache.org/repos/asf/phoenix/blob/19012c02/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
index 0ba87c7..f630207 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
@@ -1221,18 +1221,16 @@ public class UpgradeUtil {
 
     public static boolean truncateStats(HTableInterface metaTable, HTableInterface statsTable)
             throws IOException, InterruptedException {
-        List<Cell> columnCells = metaTable
-                .get(new Get(SchemaUtil.getTableKey(null, PhoenixDatabaseMetaData.SYSTEM_SCHEMA_NAME,
-                        PhoenixDatabaseMetaData.SYSTEM_CATALOG_TABLE)))
+        byte[] statsTableKey = SchemaUtil.getTableKey(null, PhoenixDatabaseMetaData.SYSTEM_SCHEMA_NAME,
+                PhoenixDatabaseMetaData.SYSTEM_STATS_TABLE);
+        List<Cell> columnCells = metaTable.get(new Get(statsTableKey))
                 .getColumnCells(PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES, QueryConstants.EMPTY_COLUMN_BYTES);
-        if (!columnCells.isEmpty()
-                && columnCells.get(0).getTimestamp() < MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0)
{
+        long timestamp;
+        if (!columnCells.isEmpty() && (timestamp = columnCells.get(0)
+                .getTimestamp()) < MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0)
{
 
-            byte[] statsTableKey = SchemaUtil.getTableKey(null, PhoenixDatabaseMetaData.SYSTEM_SCHEMA_NAME,
-                    PhoenixDatabaseMetaData.SYSTEM_STATS_TABLE);
             KeyValue upgradeKV = KeyValueUtil.newKeyValue(statsTableKey, PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES,
-                    UPGRADE_TO_4_7_COLUMN_NAME, MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0
- 1,
-                    ByteUtil.EMPTY_BYTE_ARRAY);
+                    UPGRADE_TO_4_7_COLUMN_NAME, timestamp, PBoolean.INSTANCE.toBytes(true));
             Put upgradePut = new Put(statsTableKey);
             upgradePut.add(upgradeKV);
 


Mime
View raw message