Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 493c5f201 -> 66ab7ffb5


PHOENIX-2622 Writes to transactional table get slower after regions splits to 
multiple region servers


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/66ab7ffb
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/66ab7ffb
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/66ab7ffb

Branch: refs/heads/4.x-HBase-0.98
Commit: 66ab7ffb580a11d34d145512e544ca3b72e31f8c
Parents: 493c5f2
Author: James Taylor <jamestay...@apache.org>
Authored: Fri Jan 22 17:21:58 2016 -0800
Committer: James Taylor <jamestay...@apache.org>
Committed: Fri Jan 22 17:21:58 2016 -0800

----------------------------------------------------------------------
 .../apache/phoenix/execute/MutationState.java   | 29 +++++++++++++-------
 .../apache/phoenix/jdbc/PhoenixStatement.java   |  1 -
 2 files changed, 19 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/66ab7ffb/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java 
b/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
index 07a1e52..fe9c5ea 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
@@ -52,7 +52,6 @@ import 
org.apache.phoenix.coprocessor.MetaDataProtocol.MetaDataMutationResult;
 import org.apache.phoenix.exception.SQLExceptionCode;
 import org.apache.phoenix.exception.SQLExceptionInfo;
 import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
-import org.apache.phoenix.hbase.index.util.KeyValueBuilder;
 import org.apache.phoenix.index.IndexMaintainer;
 import org.apache.phoenix.index.IndexMetaDataCacheClient;
 import org.apache.phoenix.index.PhoenixIndexCodec;
@@ -85,7 +84,6 @@ import org.apache.phoenix.util.LogUtil;
 import org.apache.phoenix.util.PhoenixRuntime;
 import org.apache.phoenix.util.SQLCloseable;
 import org.apache.phoenix.util.SQLCloseables;
-import org.apache.phoenix.util.SchemaUtil;
 import org.apache.phoenix.util.ServerUtil;
 import org.apache.phoenix.util.TransactionUtil;
 import org.cloudera.htrace.Span;
@@ -216,7 +214,7 @@ public class MutationState implements SQLCloseable {
      */
     public void commitDDLFence(PTable dataTable) throws SQLException {
         if (dataTable.isTransactional()) {
-            byte[] key = SchemaUtil.getTableKey(dataTable);
+            byte[] key = dataTable.getName().getBytes();
             boolean success = false;
             try {
                 FenceWait fenceWait = VisibilityFence.prepareWait(key, 
connection.getQueryServices().getTransactionSystemClient());
@@ -250,18 +248,28 @@ public class MutationState implements SQLCloseable {
      * These entries will not conflict with each other, but they will conflict 
with a
      * DDL operation of creating an index. See {@link #addDMLFence(PTable)} 
and TEPHRA-157
      * for more information.
-     * @param dataTable the table which is doing DML
+     * @param table the table which is doing DML
      * @throws SQLException
      */
-    public void addDMLFence(PTable dataTable) throws SQLException {
+    private void addDMLFence(PTable table) throws SQLException {
+        if (table.getType() == PTableType.INDEX || !table.isTransactional()) {
+            return;
+        }
+        byte[] logicalKey = table.getName().getBytes();
+        TransactionAware logicalTxAware = VisibilityFence.create(logicalKey);
         if (this.txContext == null) {
-            throw new 
SQLExceptionInfo.Builder(SQLExceptionCode.NULL_TRANSACTION_CONTEXT).build().buildException();
+            this.txAwares.add(logicalTxAware);
+        } else {
+            this.txContext.addTransactionAware(logicalTxAware);
         }
-        byte[] logicalKey = SchemaUtil.getTableKey(dataTable);
-        this.txContext.addTransactionAware(VisibilityFence.create(logicalKey));
-        byte[] physicalKey = dataTable.getPhysicalName().getBytes();
+        byte[] physicalKey = table.getPhysicalName().getBytes();
         if (Bytes.compareTo(physicalKey, logicalKey) != 0) {
-            
this.txContext.addTransactionAware(VisibilityFence.create(physicalKey));
+            TransactionAware physicalTxAware = 
VisibilityFence.create(physicalKey);
+            if (this.txContext == null) {
+                this.txAwares.add(physicalTxAware);
+            } else {
+                this.txContext.addTransactionAware(physicalTxAware);
+            }
         }
     }
     
@@ -878,6 +886,7 @@ public class MutationState implements SQLCloseable {
                 // Track tables to which we've sent uncommitted data
                 if (isTransactional = table.isTransactional()) {
                     txTableRefs.add(tableRef);
+                    addDMLFence(table);
                     
uncommittedPhysicalNames.add(table.getPhysicalName().getString());
                 }
                 boolean isDataTable = true;

http://git-wip-us.apache.org/repos/asf/phoenix/blob/66ab7ffb/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java 
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java
index e05b69b..f36bbd8 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java
@@ -328,7 +328,6 @@ public class PhoenixStatement implements Statement, 
SQLCloseable {
                                 MutationPlan plan = 
stmt.compilePlan(PhoenixStatement.this, Sequence.ValueOp.VALIDATE_SEQUENCE);
                                 if (plan.getTargetRef() != null && 
plan.getTargetRef().getTable() != null && 
plan.getTargetRef().getTable().isTransactional()) {
                                     state.startTransaction();
-                                    
state.addDMLFence(plan.getTargetRef().getTable());
                                 }
                                 Iterator<TableRef> tableRefs = 
plan.getSourceRefs().iterator();
                                 state.sendUncommitted(tableRefs);

Reply via email to