Skip to content

Commit

Permalink
PHOENIX-3432 Upgrade Phoenix 4.8.0 to 4.9.0 fails because of illegal …
Browse files Browse the repository at this point in the history
…characters in snapshot name
  • Loading branch information
Samarth committed Nov 2, 2016
1 parent 8a44cc0 commit d7b821a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Expand Up @@ -32,7 +32,7 @@
import static org.apache.phoenix.query.QueryServicesOptions.DEFAULT_RENEW_LEASE_THREAD_POOL_SIZE; 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_RENEW_LEASE_THRESHOLD_MILLISECONDS;
import static org.apache.phoenix.query.QueryServicesOptions.DEFAULT_RUN_RENEW_LEASE_FREQUENCY_INTERVAL_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 static org.apache.phoenix.util.UpgradeUtil.upgradeTo4_5_0;


import java.io.IOException; import java.io.IOException;
Expand Down Expand Up @@ -2496,6 +2496,7 @@ public void upgradeSystemTables(final String url, final Properties props) throws
boolean acquiredMutexLock = false; boolean acquiredMutexLock = false;
byte[] mutexRowKey = SchemaUtil.getTableKey(null, PhoenixDatabaseMetaData.SYSTEM_CATALOG_SCHEMA, byte[] mutexRowKey = SchemaUtil.getTableKey(null, PhoenixDatabaseMetaData.SYSTEM_CATALOG_SCHEMA,
PhoenixDatabaseMetaData.SYSTEM_CATALOG_TABLE); PhoenixDatabaseMetaData.SYSTEM_CATALOG_TABLE);
boolean snapshotCreated = false;
try { try {
if (!ConnectionQueryServicesImpl.this.upgradeRequired.get()) { if (!ConnectionQueryServicesImpl.this.upgradeRequired.get()) {
throw new UpgradeNotRequiredException(); throw new UpgradeNotRequiredException();
Expand All @@ -2519,9 +2520,9 @@ public void upgradeSystemTables(final String url, final Properties props) throws
sysCatalogTableName = e.getTable().getPhysicalName().getString(); sysCatalogTableName = e.getTable().getPhysicalName().getString();
if (currentServerSideTableTimeStamp < MIN_SYSTEM_TABLE_TIMESTAMP if (currentServerSideTableTimeStamp < MIN_SYSTEM_TABLE_TIMESTAMP
&& (acquiredMutexLock = acquireUpgradeMutex(currentServerSideTableTimeStamp, mutexRowKey))) { && (acquiredMutexLock = acquireUpgradeMutex(currentServerSideTableTimeStamp, mutexRowKey))) {
snapshotName = getUpgradeSnapshotName(sysCatalogTableName, snapshotName = getSysCatalogSnapshotName(currentServerSideTableTimeStamp);
currentServerSideTableTimeStamp);
createSnapshot(snapshotName, sysCatalogTableName); createSnapshot(snapshotName, sysCatalogTableName);
snapshotCreated = true;
} }
String columnsToAdd = ""; String columnsToAdd = "";
// This will occur if we have an older SYSTEM.CATALOG and we need to update it to // This will occur if we have an older SYSTEM.CATALOG and we need to update it to
Expand Down Expand Up @@ -2813,7 +2814,9 @@ public void upgradeSystemTables(final String url, final Properties props) throws
} }
} finally { } finally {
try { try {
restoreFromSnapshot(sysCatalogTableName, snapshotName, success); if (snapshotCreated) {
restoreFromSnapshot(sysCatalogTableName, snapshotName, success);
}
} catch (SQLException e) { } catch (SQLException e) {
if (toThrow != null) { if (toThrow != null) {
toThrow.setNextException(e); toThrow.setNextException(e);
Expand Down
Expand Up @@ -1897,8 +1897,9 @@ public static void mapChildViewsToNamespace(PhoenixConnection conn, String table
} }
} }


public static final String getUpgradeSnapshotName(String tableString, long currentSystemTableTimestamp) { public static final String getSysCatalogSnapshotName(long currentSystemTableTimestamp) {
Format formatter = new SimpleDateFormat("yyyyMMddHHmmssZ"); String tableString = SYSTEM_CATALOG_NAME;
Format formatter = new SimpleDateFormat("yyyyMMddHHmmss");
String date = formatter.format(new Date(System.currentTimeMillis())); String date = formatter.format(new Date(System.currentTimeMillis()));
String upgradingFrom = getVersion(currentSystemTableTimestamp); String upgradingFrom = getVersion(currentSystemTableTimestamp);
return "SNAPSHOT_" + tableString + "_" + upgradingFrom + "_TO_" + CURRENT_CLIENT_VERSION + "_" + date; return "SNAPSHOT_" + tableString + "_" + upgradingFrom + "_TO_" + CURRENT_CLIENT_VERSION + "_" + date;
Expand Down

0 comments on commit d7b821a

Please sign in to comment.