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/02/02 05:00:06 UTC
[32/50] [abbrv] phoenix git commit: PHOENIX-2622 Writes to
transactional table get slower after regions splits to multiple region
servers
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/424083d9
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/424083d9
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/424083d9
Branch: refs/heads/calcite
Commit: 424083d9f95e2e26c40b2d443c29392dda3cc084
Parents: 81b644f
Author: James Taylor <ja...@apache.org>
Authored: Fri Jan 22 17:21:58 2016 -0800
Committer: James Taylor <ja...@apache.org>
Committed: Fri Jan 22 17:25:03 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/424083d9/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 46aa819..1658962 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
@@ -54,7 +54,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;
@@ -87,7 +86,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.slf4j.Logger;
@@ -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/424083d9/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 b54ccd5..7e8969b 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
@@ -331,7 +331,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);