You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ma...@apache.org on 2016/09/20 18:05:38 UTC
[15/47] phoenix git commit: PHOENIX-3230 Addendum to use the physical
name of system catalog and other tweaks/cleanup
PHOENIX-3230 Addendum to use the physical name of system catalog and other tweaks/cleanup
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/8e082fb5
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/8e082fb5
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/8e082fb5
Branch: refs/heads/calcite
Commit: 8e082fb5bbace7a495c5b727b2f781bba3b67cd1
Parents: d9eb45e
Author: Samarth <sa...@salesforce.com>
Authored: Fri Sep 9 14:44:46 2016 -0700
Committer: Samarth <sa...@salesforce.com>
Committed: Fri Sep 9 14:44:46 2016 -0700
----------------------------------------------------------------------
.../phoenix/coprocessor/MetaDataProtocol.java | 3 ++-
.../query/ConnectionQueryServicesImpl.java | 27 ++++++++++----------
.../apache/phoenix/query/QueryConstants.java | 2 +-
3 files changed, 17 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/8e082fb5/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 20922e5..3b57981 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
@@ -83,8 +83,9 @@ public abstract class MetaDataProtocol extends MetaDataService {
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 + 15;
public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_8_0 = MIN_TABLE_TIMESTAMP + 18;
+ public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_8_1 = MIN_TABLE_TIMESTAMP + 18;
// 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_8_0;
+ public static final long MIN_SYSTEM_TABLE_TIMESTAMP = MIN_SYSTEM_TABLE_TIMESTAMP_4_8_1;
// ALWAYS update this map whenever rolling out a new release (major, minor or patch release).
// Key is the SYSTEM.CATALOG timestamp for the version and value is the version string.
http://git-wip-us.apache.org/repos/asf/phoenix/blob/8e082fb5/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 c5d53c3..607ad5e 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
@@ -19,7 +19,7 @@ package org.apache.phoenix.query;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.hadoop.hbase.HColumnDescriptor.TTL;
import static org.apache.phoenix.coprocessor.MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP;
-import static org.apache.phoenix.coprocessor.MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_8_0;
+import static org.apache.phoenix.coprocessor.MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_8_1;
import static org.apache.phoenix.coprocessor.MetaDataProtocol.PHOENIX_MAJOR_VERSION;
import static org.apache.phoenix.coprocessor.MetaDataProtocol.PHOENIX_MINOR_VERSION;
import static org.apache.phoenix.coprocessor.MetaDataProtocol.PHOENIX_PATCH_NUMBER;
@@ -2329,7 +2329,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
if (upgradeSystemTables) {
long currentServerSideTableTimeStamp = e.getTable().getTimeStamp();
sysCatalogTableName = e.getTable().getPhysicalName().getString();
- if (currentServerSideTableTimeStamp < MIN_SYSTEM_TABLE_TIMESTAMP && acquireUpgradeMutex(currentServerSideTableTimeStamp)) {
+ if (currentServerSideTableTimeStamp < MIN_SYSTEM_TABLE_TIMESTAMP && acquireUpgradeMutex(currentServerSideTableTimeStamp, e.getTable().getPhysicalName().getBytes())) {
snapshotName = getUpgradeSnapshotName(sysCatalogTableName, currentServerSideTableTimeStamp);
createSnapshot(snapshotName, sysCatalogTableName);
}
@@ -2727,9 +2727,9 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
* making use of HBase's checkAndPut api.
* <p>
* This method was added as part of 4.8.1 release. For clients upgrading to 4.8.1, the old value in the
- * version cell will be null i.e. the QueryConstants#VERSION column will be non-existent. For client's
+ * version cell will be null i.e. the {@value QueryConstants#UPGRADE_MUTEX} column will be non-existent. For client's
* upgrading to a release newer than 4.8.1 the existing version cell will be non-null. The client which
- * wins the race will end up setting the version cell to the MetadataProtocol#MIN_SYSTEM_TABLE_TIMESTAMP
+ * wins the race will end up setting the version cell to the {@value MetaDataProtocol#MIN_SYSTEM_TABLE_TIMESTAMP}
* for the release.
* </p>
*
@@ -2737,19 +2737,20 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
* @throws IOException
* @throws SQLException
*/
- private boolean acquireUpgradeMutex(long currentServerSideTableTimestamp) throws IOException,
+ private boolean acquireUpgradeMutex(long currentServerSideTableTimestamp, byte[] sysCatalogTableName) throws IOException,
SQLException {
Preconditions.checkArgument(currentServerSideTableTimestamp < MIN_SYSTEM_TABLE_TIMESTAMP);
- try (HTableInterface sysCatalogTable = getTable(SYSTEM_CATALOG_NAME_BYTES)) {
+ try (HTableInterface sysCatalogTable = getTable(sysCatalogTableName)) {
byte[] row = SchemaUtil.getTableKey(null, PhoenixDatabaseMetaData.SYSTEM_CATALOG_SCHEMA,
- PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME);
+ PhoenixDatabaseMetaData.SYSTEM_CATALOG_TABLE);
byte[] family = PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES;
- byte[] qualifier = QueryConstants.VERSION;
- byte[] oldValue = currentServerSideTableTimestamp < MIN_SYSTEM_TABLE_TIMESTAMP_4_8_0 ? null
- : Bytes.toBytes(currentServerSideTableTimestamp);
- byte[] newValue = Bytes.toBytes(MIN_SYSTEM_TABLE_TIMESTAMP);
- long ts = MIN_SYSTEM_TABLE_TIMESTAMP;
- Put put = new Put(row, ts);
+ byte[] qualifier = QueryConstants.UPGRADE_MUTEX;
+ byte[] oldValue = currentServerSideTableTimestamp < MIN_SYSTEM_TABLE_TIMESTAMP_4_8_1 ? null
+ : PLong.INSTANCE.toBytes(currentServerSideTableTimestamp);
+ byte[] newValue = PLong.INSTANCE.toBytes(MIN_SYSTEM_TABLE_TIMESTAMP);
+ // Note that the timestamp for this put doesn't really matter since UPGRADE_MUTEX column isn't used
+ // to calculate SYSTEM.CATALOG's server side timestamp.
+ Put put = new Put(row);
put.add(family, qualifier, newValue);
boolean acquired = sysCatalogTable.checkAndPut(row, family, qualifier, oldValue, put);
if (!acquired) { throw new UpgradeInProgressException(
http://git-wip-us.apache.org/repos/asf/phoenix/blob/8e082fb5/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java
index 3077943..7e5f7a2 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java
@@ -356,6 +356,6 @@ public interface QueryConstants {
public static final byte[] OFFSET_FAMILY = "f_offset".getBytes();
public static final byte[] OFFSET_COLUMN = "c_offset".getBytes();
public static final String LAST_SCAN = "LAST_SCAN";
- public static final byte[] VERSION = "VERSION".getBytes();
+ public static final byte[] UPGRADE_MUTEX = "UPGRADE_MUTEX".getBytes();
}