Return-Path: X-Original-To: apmail-phoenix-commits-archive@minotaur.apache.org Delivered-To: apmail-phoenix-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9CB031899D for ; Mon, 15 Feb 2016 06:33:06 +0000 (UTC) Received: (qmail 39462 invoked by uid 500); 15 Feb 2016 06:33:06 -0000 Delivered-To: apmail-phoenix-commits-archive@phoenix.apache.org Received: (qmail 39419 invoked by uid 500); 15 Feb 2016 06:33:06 -0000 Mailing-List: contact commits-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list commits@phoenix.apache.org Received: (qmail 39410 invoked by uid 99); 15 Feb 2016 06:33:06 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Feb 2016 06:33:06 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0347EE0248; Mon, 15 Feb 2016 06:33:06 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ankit@apache.org To: commits@phoenix.apache.org Message-Id: <6d4cd2985d48454d93a41810427498af@git.apache.org> X-Mailer: ASF-Git Admin Mailer 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 +0000 (UTC) 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 Authored: Mon Feb 15 12:03:21 2016 +0530 Committer: Ankit Singhal 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 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 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);