[ 
https://issues.apache.org/jira/browse/PHOENIX-6129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17215050#comment-17215050
 ] 

ASF GitHub Bot commented on PHOENIX-6129:
-----------------------------------------

ChinmaySKulkarni commented on a change in pull request #920:
URL: https://github.com/apache/phoenix/pull/920#discussion_r505900118



##########
File path: 
phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
##########
@@ -4294,11 +4295,9 @@ 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();

Review comment:
       @virajjasani I think there is some confusion here. The aim of this Jira 
is to reduce the HBase calls to get the table. Currently, the call to 
`writeMutexCell()` calls `getSysMutexPhysicalTableNameBytes()` which does 1 or 
2 HBase admin calls (tableExists()) and then we still do a getTable() call 
[here](https://github.com/apache/phoenix/blob/628fa0db239985b2972f51459540f7513d182885/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java#L4305).
 
   The same happens for `deleteMutexCell()`. 
   
   Instead of calling `getSysMutexPhysicalTableNameBytes()`, we can do 1 
getTable call with `SYSTEM.MUTEX` and if that throws a TNFE, try again with 
`SYSTEM:MUTEX` thus eliminating the `tableExists()` calls.
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Remove unnecessary HBase admin API calls when writing and deleting mutex cells
> ------------------------------------------------------------------------------
>
>                 Key: PHOENIX-6129
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-6129
>             Project: Phoenix
>          Issue Type: Improvement
>    Affects Versions: 5.0.0, 4.15.0
>            Reporter: Chinmay Kulkarni
>            Assignee: Viraj Jasani
>            Priority: Major
>              Labels: phoenix-hardening, quality-improvement
>             Fix For: 5.1.0, 4.16.0
>
>
> Inside CQSI.writeMutexCell(), we call 
> [getSysMutexPhysicalTableNameBytes()|https://github.com/apache/phoenix/blob/e3c7b4bdce2524eb4fd1e7eb0ccd3454fcca81ce/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java#L4244]
>  which in turn calls HBase Admin APIs to check the existence of 
> SYSTEM.MUTEX/SYSTEM:MUTEX 
> [here|https://github.com/apache/phoenix/blob/e3c7b4bdce2524eb4fd1e7eb0ccd3454fcca81ce/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java#L4309-L4312].
> Later, we anyways try to get the HTable both inside 
> [writeMutexCell()|https://github.com/apache/phoenix/blob/e3c7b4bdce2524eb4fd1e7eb0ccd3454fcca81ce/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java#L4245]
>  and 
> [deleteMutexCell()|https://github.com/apache/phoenix/blob/e3c7b4bdce2524eb4fd1e7eb0ccd3454fcca81ce/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java#L4289].
>  Instead, we can lazily fail this getTable() call (by catching the HBase 
> TableNotFoundException) to avoid additional HBase Admin API calls.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to