Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 63D11200BB3 for ; Wed, 2 Nov 2016 18:50:16 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 60D36160AFB; Wed, 2 Nov 2016 17:50:16 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id AB715160AF0 for ; Wed, 2 Nov 2016 18:50:15 +0100 (CET) Received: (qmail 25253 invoked by uid 500); 2 Nov 2016 17:50:14 -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 25243 invoked by uid 99); 2 Nov 2016 17:50:14 -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; Wed, 02 Nov 2016 17:50:14 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C35BFE09DE; Wed, 2 Nov 2016 17:50:14 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: samarth@apache.org To: commits@phoenix.apache.org Message-Id: <50de563eb7cf4d21ae042ea4c15d66a6@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: phoenix git commit: PHOENIX-3432 Upgrade Phoenix 4.8.0 to 4.9.0 fails because of illegal characters in snapshot name Date: Wed, 2 Nov 2016 17:50:14 +0000 (UTC) archived-at: Wed, 02 Nov 2016 17:50:16 -0000 Repository: phoenix Updated Branches: refs/heads/4.x-HBase-0.98 c5fed780e -> 1ed90b6a2 PHOENIX-3432 Upgrade Phoenix 4.8.0 to 4.9.0 fails because of illegal characters in snapshot name Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/1ed90b6a Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/1ed90b6a Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/1ed90b6a Branch: refs/heads/4.x-HBase-0.98 Commit: 1ed90b6a2b48013923f5a84f7b4d7c759825e82d Parents: c5fed78 Author: Samarth Authored: Wed Nov 2 10:49:18 2016 -0700 Committer: Samarth Committed: Wed Nov 2 10:49:49 2016 -0700 ---------------------------------------------------------------------- .../phoenix/query/ConnectionQueryServicesImpl.java | 11 +++++++---- .../main/java/org/apache/phoenix/util/UpgradeUtil.java | 5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/1ed90b6a/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 ff4e404..b1b7bab 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 @@ -33,7 +33,7 @@ import static org.apache.phoenix.query.QueryServicesOptions.DEFAULT_RENEW_LEASE_ import static org.apache.phoenix.query.QueryServicesOptions.DEFAULT_RENEW_LEASE_THREAD_POOL_SIZE; import static org.apache.phoenix.query.QueryServicesOptions.DEFAULT_RENEW_LEASE_THRESHOLD_MILLISECONDS; import static org.apache.phoenix.query.QueryServicesOptions.DEFAULT_RUN_RENEW_LEASE_FREQUENCY_INTERVAL_MILLISECONDS; -import static org.apache.phoenix.util.UpgradeUtil.getUpgradeSnapshotName; +import static org.apache.phoenix.util.UpgradeUtil.getSysCatalogSnapshotName; import static org.apache.phoenix.util.UpgradeUtil.upgradeTo4_5_0; import java.io.IOException; @@ -2493,6 +2493,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement boolean acquiredMutexLock = false; byte[] mutexRowKey = SchemaUtil.getTableKey(null, PhoenixDatabaseMetaData.SYSTEM_CATALOG_SCHEMA, PhoenixDatabaseMetaData.SYSTEM_CATALOG_TABLE); + boolean snapshotCreated = false; try { if (!ConnectionQueryServicesImpl.this.upgradeRequired.get()) { throw new UpgradeNotRequiredException(); @@ -2516,9 +2517,9 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement sysCatalogTableName = e.getTable().getPhysicalName().getString(); if (currentServerSideTableTimeStamp < MIN_SYSTEM_TABLE_TIMESTAMP && (acquiredMutexLock = acquireUpgradeMutex(currentServerSideTableTimeStamp, mutexRowKey))) { - snapshotName = getUpgradeSnapshotName(sysCatalogTableName, - currentServerSideTableTimeStamp); + snapshotName = getSysCatalogSnapshotName(currentServerSideTableTimeStamp); createSnapshot(snapshotName, sysCatalogTableName); + snapshotCreated = true; } String columnsToAdd = ""; // This will occur if we have an older SYSTEM.CATALOG and we need to update it to @@ -2810,7 +2811,9 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement } } finally { try { - restoreFromSnapshot(sysCatalogTableName, snapshotName, success); + if (snapshotCreated) { + restoreFromSnapshot(sysCatalogTableName, snapshotName, success); + } } catch (SQLException e) { if (toThrow != null) { toThrow.setNextException(e); http://git-wip-us.apache.org/repos/asf/phoenix/blob/1ed90b6a/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 df283c5..2b04ac1 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 @@ -1899,8 +1899,9 @@ public class UpgradeUtil { } } - public static final String getUpgradeSnapshotName(String tableString, long currentSystemTableTimestamp) { - Format formatter = new SimpleDateFormat("yyyyMMddHHmmssZ"); + public static final String getSysCatalogSnapshotName(long currentSystemTableTimestamp) { + String tableString = SYSTEM_CATALOG_NAME; + Format formatter = new SimpleDateFormat("yyyyMMddHHmmss"); String date = formatter.format(new Date(System.currentTimeMillis())); String upgradingFrom = getVersion(currentSystemTableTimestamp); return "SNAPSHOT_" + tableString + "_" + upgradingFrom + "_TO_" + CURRENT_CLIENT_VERSION + "_" + date;