Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1k
PHOENIX-6129 : Optimize tableExists() call while retrieving correct MUTEX table#920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ChinmaySKulkarni
merged 8 commits into
apache:master
from
virajjasani:PHOENIX-6129-masterOct 26, 2020
+61
−31
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5e3b5d9
PHOENIX-6129 : Avoid redundant Admin API call in the absence of SYSTE…
virajjasani 9aafabf
removing redundant call to getSysMutexPhysicalTableNameBytes() from a…
virajjasani 30e1a9e
Revert "removing redundant call to getSysMutexPhysicalTableNameBytes(…
virajjasani c0abcd6
checkstyle fix
virajjasani da48686
incorporating review
virajjasani f376592
Merge branch 'master' of github.com:apache/phoenix into PHOENIX-6129-…
virajjasani ecf175e
Merge branch 'master' of github.com:apache/phoenix into PHOENIX-6129-…
virajjasani d341b40
addressing review
virajjasani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
52 changes: 21 additions & 31 deletions
52 phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -4359,19 +4359,12 @@ void ensureSystemTablesMigratedToSystemNamespace() | ||
| * making use of HBase's checkAndPut api. | ||
| * | ||
| * @return true if client won the race, false otherwise | ||
| * @throws IOException | ||
| * @throws SQLException | ||
| */ | ||
| @VisibleForTesting | ||
| public boolean acquireUpgradeMutex(long currentServerSideTableTimestamp) | ||
| throws IOException, | ||
| SQLException { | ||
| throws SQLException { | ||
| Preconditions.checkArgument(currentServerSideTableTimestamp < MIN_SYSTEM_TABLE_TIMESTAMP); | ||
| byte[] sysMutexPhysicalTableNameBytes = getSysMutexPhysicalTableNameBytes(); | ||
| if(sysMutexPhysicalTableNameBytes == null) { | ||
| throw new UpgradeInProgressException(getVersion(currentServerSideTableTimestamp), | ||
| getVersion(MIN_SYSTEM_TABLE_TIMESTAMP)); | ||
| } | ||
| if (!writeMutexCell(null, PhoenixDatabaseMetaData.SYSTEM_CATALOG_SCHEMA, | ||
| PhoenixDatabaseMetaData.SYSTEM_CATALOG_TABLE, null, null)) { | ||
| throw new UpgradeInProgressException(getVersion(currentServerSideTableTimestamp), | ||
| @@ -4384,15 +4377,13 @@ public boolean acquireUpgradeMutex(long currentServerSideTableTimestamp) | ||
| public boolean writeMutexCell(String tenantId, String schemaName, String tableName, | ||
| String columnName, String familyName) throws SQLException { | ||
| try { | ||
| byte[] rowKey = | ||
| columnName != null | ||
| ? SchemaUtil.getColumnKey(tenantId, schemaName, tableName, columnName, | ||
| familyName) | ||
| : SchemaUtil.getTableKey(tenantId, schemaName, tableName); | ||
| byte[] rowKey = columnName != null | ||
| ? SchemaUtil.getColumnKey(tenantId, schemaName, tableName, | ||
| columnName, familyName) | ||
| : SchemaUtil.getTableKey(tenantId, schemaName, tableName); | ||
| // at this point the system mutex table should have been created or | ||
| // an exception thrown | ||
| byte[] sysMutexPhysicalTableNameBytes = getSysMutexPhysicalTableNameBytes(); | ||
| try (Table sysMutexTable = getTable(sysMutexPhysicalTableNameBytes)) { | ||
| try (Table sysMutexTable = getSysMutexTable()) { | ||
| byte[] family = PhoenixDatabaseMetaData.SYSTEM_MUTEX_FAMILY_NAME_BYTES; | ||
| byte[] qualifier = PhoenixDatabaseMetaData.SYSTEM_MUTEX_COLUMN_NAME_BYTES; | ||
| byte[] value = MUTEX_LOCKED; | ||
| @@ -4428,15 +4419,13 @@ public void releaseUpgradeMutex() throws IOException, SQLException { | ||
| public void deleteMutexCell(String tenantId, String schemaName, String tableName, | ||
| String columnName, String familyName) throws SQLException { | ||
| try { | ||
| byte[] rowKey = | ||
| columnName != null | ||
| ? SchemaUtil.getColumnKey(tenantId, schemaName, tableName, columnName, | ||
| familyName) | ||
| : SchemaUtil.getTableKey(tenantId, schemaName, tableName); | ||
| byte[] rowKey = columnName != null | ||
| ? SchemaUtil.getColumnKey(tenantId, schemaName, tableName, | ||
| columnName, familyName) | ||
| : SchemaUtil.getTableKey(tenantId, schemaName, tableName); | ||
| // at this point the system mutex table should have been created or | ||
| // an exception thrown | ||
| byte[] sysMutexPhysicalTableNameBytes = getSysMutexPhysicalTableNameBytes(); | ||
| try (Table sysMutexTable = getTable(sysMutexPhysicalTableNameBytes)) { | ||
| try (Table sysMutexTable = getSysMutexTable()) { | ||
| byte[] family = PhoenixDatabaseMetaData.SYSTEM_MUTEX_FAMILY_NAME_BYTES; | ||
| byte[] qualifier = PhoenixDatabaseMetaData.SYSTEM_MUTEX_COLUMN_NAME_BYTES; | ||
| Delete delete = new Delete(rowKey); | ||
| @@ -4454,17 +4443,18 @@ public void deleteMutexCell(String tenantId, String schemaName, String tableName | ||
| } | ||
| } | ||
| private byte[] getSysMutexPhysicalTableNameBytes() throws IOException, SQLException { | ||
| byte[] sysMutexPhysicalTableNameBytes = null; | ||
| try(Admin admin = getAdmin()) { | ||
| if(admin.tableExists(PhoenixDatabaseMetaData.SYSTEM_MUTEX_HBASE_TABLE_NAME)) { | ||
| sysMutexPhysicalTableNameBytes = PhoenixDatabaseMetaData.SYSTEM_MUTEX_NAME_BYTES; | ||
| } else if (admin.tableExists(TableName.valueOf( | ||
| SchemaUtil.getPhysicalTableName(SYSTEM_MUTEX_NAME, props).getName()))) { | ||
| sysMutexPhysicalTableNameBytes = SchemaUtil.getPhysicalTableName(SYSTEM_MUTEX_NAME, props).getName(); | ||
| @VisibleForTesting | ||
| public Table getSysMutexTable() throws SQLException, IOException { | ||
| String table = SYSTEM_MUTEX_NAME; | ||
| TableName tableName = TableName.valueOf(table); | ||
| try (Admin admin = getAdmin()) { | ||
| if (!admin.tableExists(tableName)) { | ||
| table = table.replace(QueryConstants.NAME_SEPARATOR, | ||
| QueryConstants.NAMESPACE_SEPARATOR); | ||
| tableName = TableName.valueOf(table); | ||
| } | ||
| return connection.getTable(tableName); | ||
ChinmaySKulkarni marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| return sysMutexPhysicalTableNameBytes; | ||
| } | ||
| private String addColumn(String columnsToAddSoFar, String columns) { | ||
40 changes: 40 additions & 0 deletions
40 phoenix-core/src/test/java/org/apache/phoenix/query/ConnectionQueryServicesImplTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.