You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by td...@apache.org on 2015/11/23 22:51:14 UTC

[2/3] phoenix git commit: more review feedback

more review feedback


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

Branch: refs/heads/txn
Commit: b77bb9a97791abb5c76a24c08497be91a0f2b3d3
Parents: d3032be
Author: Thomas D'Silva <td...@salesforce.com>
Authored: Sat Nov 21 21:27:35 2015 -0800
Committer: Thomas D'Silva <td...@salesforce.com>
Committed: Mon Nov 23 13:47:38 2015 -0800

----------------------------------------------------------------------
 .../phoenix/end2end/index/MutableIndexIT.java   |  21 +-
 .../coprocessor/MetaDataEndpointImpl.java       |   2 +-
 .../apache/phoenix/execute/AggregatePlan.java   |   1 -
 .../execute/DelegateHTableInterface.java        | 300 -------------------
 .../apache/phoenix/execute/MutationState.java   |  70 +++--
 .../apache/phoenix/util/TransactionUtil.java    |   4 +-
 6 files changed, 51 insertions(+), 347 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/b77bb9a9/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java
index 9a70246..8f5301c 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java
@@ -475,15 +475,16 @@ public class MutableIndexIT extends BaseHBaseManagedTimeIT {
     @Test
     public void testUpsertingNullForIndexedColumns() throws Exception {
     	Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        String testTableName = tableName + "_" + System.currentTimeMillis();
         try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
 	        conn.setAutoCommit(false);
 	        ResultSet rs;
     		Statement stmt = conn.createStatement();
-    		stmt.execute("CREATE TABLE " + fullTableName + "(v1 VARCHAR PRIMARY KEY, v2 DOUBLE, v3 VARCHAR) "+tableDDLOptions);
-    		stmt.execute("CREATE " + (localIndex ? "LOCAL" : "") + " INDEX " + indexName + " ON " + fullTableName + "  (v2) INCLUDE(v3)");
+    		stmt.execute("CREATE TABLE " + testTableName + "(v1 VARCHAR PRIMARY KEY, v2 DOUBLE, v3 VARCHAR) "+tableDDLOptions);
+    		stmt.execute("CREATE " + (localIndex ? "LOCAL" : "") + " INDEX " + indexName + " ON " + testTableName + "  (v2) INCLUDE(v3)");
     		
     		//create a row with value null for indexed column v2
-    		stmt.executeUpdate("upsert into " + fullTableName + " values('cc1', null, 'abc')");
+    		stmt.executeUpdate("upsert into " + testTableName + " values('cc1', null, 'abc')");
     		conn.commit();
     		
     		//assert values in index table 
@@ -496,7 +497,7 @@ public class MutableIndexIT extends BaseHBaseManagedTimeIT {
     		assertFalse(rs.next());
     		
     		//assert values in data table
-    		rs = stmt.executeQuery("select v1, v2, v3 from " + fullTableName);
+    		rs = stmt.executeQuery("select v1, v2, v3 from " + testTableName);
     		assertTrue(rs.next());
     		assertEquals("cc1", rs.getString(1));
     		assertEquals(0, Doubles.compare(0, rs.getDouble(2)));
@@ -505,11 +506,11 @@ public class MutableIndexIT extends BaseHBaseManagedTimeIT {
     		assertFalse(rs.next());
     		
     		//update the previously null value for indexed column v2 to a non-null value 1.23
-    		stmt.executeUpdate("upsert into " + fullTableName + " values('cc1', 1.23, 'abc')");
+    		stmt.executeUpdate("upsert into " + testTableName + " values('cc1', 1.23, 'abc')");
     		conn.commit();
     		
     		//assert values in data table
-    		rs = stmt.executeQuery("select /*+ NO_INDEX */ v1, v2, v3 from " + fullTableName);
+    		rs = stmt.executeQuery("select /*+ NO_INDEX */ v1, v2, v3 from " + testTableName);
     		assertTrue(rs.next());
     		assertEquals("cc1", rs.getString(1));
     		assertEquals(0, Doubles.compare(1.23, rs.getDouble(2)));
@@ -517,7 +518,7 @@ public class MutableIndexIT extends BaseHBaseManagedTimeIT {
     		assertFalse(rs.next());
     		
     		//assert values in index table 
-    		rs = stmt.executeQuery("select * from " + fullIndexName);
+    		rs = stmt.executeQuery("select * from " + indexName);
     		assertTrue(rs.next());
     		assertEquals(0, Doubles.compare(1.23, rs.getDouble(1)));
     		assertEquals("cc1", rs.getString(2));
@@ -525,11 +526,11 @@ public class MutableIndexIT extends BaseHBaseManagedTimeIT {
     		assertFalse(rs.next());
     		
     		//update the value for indexed column v2 back to null
-    		stmt.executeUpdate("upsert into " + fullTableName + " values('cc1', null, 'abc')");
+    		stmt.executeUpdate("upsert into " + testTableName + " values('cc1', null, 'abc')");
     		conn.commit();
     		
     		//assert values in index table 
-    		rs = stmt.executeQuery("select * from " + fullIndexName);
+    		rs = stmt.executeQuery("select * from " + indexName);
     		assertTrue(rs.next());
     		assertEquals(0, Doubles.compare(0, rs.getDouble(1)));
     		assertTrue(rs.wasNull());
@@ -538,7 +539,7 @@ public class MutableIndexIT extends BaseHBaseManagedTimeIT {
     		assertFalse(rs.next());
     		
     		//assert values in data table
-    		rs = stmt.executeQuery("select v1, v2, v3 from " + fullTableName);
+    		rs = stmt.executeQuery("select v1, v2, v3 from " + testTableName);
     		assertTrue(rs.next());
     		assertEquals("cc1", rs.getString(1));
     		assertEquals(0, Doubles.compare(0, rs.getDouble(2)));

http://git-wip-us.apache.org/repos/asf/phoenix/blob/b77bb9a9/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
index 5743f50..0a313be 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
@@ -1228,7 +1228,7 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso
                 // exists without making an additional query
                 PTable table =
                         loadTable(env, tableKey, cacheKey, clientTimeStamp, HConstants.LATEST_TIMESTAMP);
-                if (table != null && !isTableDeleted(table)) {
+                if (table != null) {
                     if (table.getTimeStamp() < clientTimeStamp) {
                         // If the table is older than the client time stamp and it's deleted,
                         // continue

http://git-wip-us.apache.org/repos/asf/phoenix/blob/b77bb9a9/phoenix-core/src/main/java/org/apache/phoenix/execute/AggregatePlan.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/AggregatePlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/AggregatePlan.java
index 3da1bea..e4f0fbe 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/AggregatePlan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/AggregatePlan.java
@@ -51,7 +51,6 @@ import org.apache.phoenix.iterate.ResultIterator;
 import org.apache.phoenix.iterate.SequenceResultIterator;
 import org.apache.phoenix.iterate.SpoolingResultIterator;
 import org.apache.phoenix.iterate.UngroupedAggregatingResultIterator;
-import org.apache.phoenix.jdbc.PhoenixStatement.Operation;
 import org.apache.phoenix.parse.FilterableStatement;
 import org.apache.phoenix.query.KeyRange;
 import org.apache.phoenix.query.QueryServices;

http://git-wip-us.apache.org/repos/asf/phoenix/blob/b77bb9a9/phoenix-core/src/main/java/org/apache/phoenix/execute/DelegateHTableInterface.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/DelegateHTableInterface.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/DelegateHTableInterface.java
deleted file mode 100644
index 7eb3c3a..0000000
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/DelegateHTableInterface.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.phoenix.execute;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HTableDescriptor;
-import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.client.Append;
-import org.apache.hadoop.hbase.client.Delete;
-import org.apache.hadoop.hbase.client.Durability;
-import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HTableInterface;
-import org.apache.hadoop.hbase.client.Increment;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.client.ResultScanner;
-import org.apache.hadoop.hbase.client.Row;
-import org.apache.hadoop.hbase.client.RowMutations;
-import org.apache.hadoop.hbase.client.Scan;
-import org.apache.hadoop.hbase.client.coprocessor.Batch.Call;
-import org.apache.hadoop.hbase.client.coprocessor.Batch.Callback;
-import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
-import org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel;
-
-import com.google.protobuf.Descriptors.MethodDescriptor;
-import com.google.protobuf.Message;
-import com.google.protobuf.Service;
-import com.google.protobuf.ServiceException;
-
-public class DelegateHTableInterface implements HTableInterface {
-    protected final HTableInterface delegate;
-
-    public DelegateHTableInterface(HTableInterface delegate) {
-        this.delegate = delegate;
-    }
-
-    @Override
-    public byte[] getTableName() {
-        return delegate.getTableName();
-    }
-
-    @Override
-    public TableName getName() {
-        return delegate.getName();
-    }
-
-    @Override
-    public Configuration getConfiguration() {
-        return delegate.getConfiguration();
-    }
-
-    @Override
-    public HTableDescriptor getTableDescriptor() throws IOException {
-        return delegate.getTableDescriptor();
-    }
-
-    @Override
-    public boolean exists(Get get) throws IOException {
-        return delegate.exists(get);
-    }
-
-    @Override
-    public Boolean[] exists(List<Get> gets) throws IOException {
-        return delegate.exists(gets);
-    }
-
-    @Override
-    public void batch(List<? extends Row> actions, Object[] results) throws IOException, InterruptedException {
-        delegate.batch(actions, results);
-    }
-
-    @SuppressWarnings("deprecation")
-    @Override
-    public Object[] batch(List<? extends Row> actions) throws IOException, InterruptedException {
-        return delegate.batch(actions);
-    }
-
-    @Override
-    public <R> void batchCallback(List<? extends Row> actions, Object[] results, Callback<R> callback)
-            throws IOException, InterruptedException {
-        delegate.batchCallback(actions, results, callback);
-    }
-
-    @SuppressWarnings("deprecation")
-    @Override
-    public <R> Object[] batchCallback(List<? extends Row> actions, Callback<R> callback) throws IOException,
-            InterruptedException {
-        return delegate.batchCallback(actions, callback);
-    }
-
-    @Override
-    public Result get(Get get) throws IOException {
-        return delegate.get(get);
-    }
-
-    @Override
-    public Result[] get(List<Get> gets) throws IOException {
-        return delegate.get(gets);
-    }
-
-    @SuppressWarnings("deprecation")
-    @Override
-    public Result getRowOrBefore(byte[] row, byte[] family) throws IOException {
-        return delegate.getRowOrBefore(row, family);
-    }
-
-    @Override
-    public ResultScanner getScanner(Scan scan) throws IOException {
-        return delegate.getScanner(scan);
-    }
-
-    @Override
-    public ResultScanner getScanner(byte[] family) throws IOException {
-        return delegate.getScanner(family);
-    }
-
-    @Override
-    public ResultScanner getScanner(byte[] family, byte[] qualifier) throws IOException {
-        return delegate.getScanner(family, qualifier);
-    }
-
-    @Override
-    public void put(Put put) throws IOException {
-        delegate.put(put);
-    }
-
-    @Override
-    public void put(List<Put> puts) throws IOException {
-        delegate.put(puts);
-    }
-
-    @Override
-    public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, byte[] value, Put put) throws IOException {
-        return delegate.checkAndPut(row, family, qualifier, value, put);
-    }
-
-    @Override
-    public void delete(Delete delete) throws IOException {
-        delegate.delete(delete);
-    }
-
-    @Override
-    public void delete(List<Delete> deletes) throws IOException {
-        delegate.delete(deletes);
-    }
-
-    @Override
-    public boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier, byte[] value, Delete delete)
-            throws IOException {
-        return delegate.checkAndDelete(row, family, qualifier, value, delete);
-    }
-
-    @Override
-    public void mutateRow(RowMutations rm) throws IOException {
-        delegate.mutateRow(rm);
-    }
-
-    @Override
-    public Result append(Append append) throws IOException {
-        return delegate.append(append);
-    }
-
-    @Override
-    public Result increment(Increment increment) throws IOException {
-        return delegate.increment(increment);
-    }
-
-    @Override
-    public long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount) throws IOException {
-        return delegate.incrementColumnValue(row, family, qualifier, amount);
-    }
-
-    @Override
-    public long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount, Durability durability)
-            throws IOException {
-        return delegate.incrementColumnValue(row, family, qualifier, amount, durability);
-    }
-
-    @SuppressWarnings("deprecation")
-    @Override
-    public long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount, boolean writeToWAL)
-            throws IOException {
-        return delegate.incrementColumnValue(row, family, qualifier, amount, writeToWAL);
-    }
-
-    @Override
-    public boolean isAutoFlush() {
-        return delegate.isAutoFlush();
-    }
-
-    @Override
-    public void flushCommits() throws IOException {
-        delegate.flushCommits();
-    }
-
-    @Override
-    public void close() throws IOException {
-        delegate.close();
-    }
-
-    @Override
-    public CoprocessorRpcChannel coprocessorService(byte[] row) {
-        return delegate.coprocessorService(row);
-    }
-
-    @Override
-    public <T extends Service, R> Map<byte[], R> coprocessorService(Class<T> service, byte[] startKey, byte[] endKey,
-            Call<T, R> callable) throws ServiceException, Throwable {
-        return delegate.coprocessorService(service, startKey, endKey, callable);
-    }
-
-    @Override
-    public <T extends Service, R> void coprocessorService(Class<T> service, byte[] startKey, byte[] endKey,
-            Call<T, R> callable, Callback<R> callback) throws ServiceException, Throwable {
-        delegate.coprocessorService(service, startKey, endKey, callable, callback);
-    }
-
-    @SuppressWarnings("deprecation")
-    @Override
-    public void setAutoFlush(boolean autoFlush) {
-        delegate.setAutoFlush(autoFlush);
-    }
-
-    @Override
-    public void setAutoFlush(boolean autoFlush, boolean clearBufferOnFail) {
-        delegate.setAutoFlush(autoFlush, clearBufferOnFail);
-    }
-
-    @Override
-    public void setAutoFlushTo(boolean autoFlush) {
-        delegate.setAutoFlushTo(autoFlush);
-    }
-
-    @Override
-    public long getWriteBufferSize() {
-        return delegate.getWriteBufferSize();
-    }
-
-    @Override
-    public void setWriteBufferSize(long writeBufferSize) throws IOException {
-        delegate.setWriteBufferSize(writeBufferSize);
-    }
-
-    @Override
-    public <R extends Message> Map<byte[], R> batchCoprocessorService(MethodDescriptor methodDescriptor,
-            Message request, byte[] startKey, byte[] endKey, R responsePrototype) throws ServiceException, Throwable {
-        return delegate.batchCoprocessorService(methodDescriptor, request, startKey, endKey, responsePrototype);
-    }
-
-    @Override
-    public <R extends Message> void batchCoprocessorService(MethodDescriptor methodDescriptor, Message request,
-            byte[] startKey, byte[] endKey, R responsePrototype, Callback<R> callback) throws ServiceException,
-            Throwable {
-        delegate.batchCoprocessorService(methodDescriptor, request, startKey, endKey, responsePrototype, callback);
-    }
-
-    @Override
-    public boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareOp compareOp, byte[] value,
-            RowMutations mutation) throws IOException {
-        return delegate.checkAndMutate(row, family, qualifier, compareOp, value, mutation);
-    }
-
-	@Override
-	public boolean[] existsAll(List<Get> gets) throws IOException {
-		return delegate.existsAll(gets);
-	}
-
-	@Override
-	public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier,
-			CompareOp compareOp, byte[] value, Put put) throws IOException {
-		return delegate.checkAndPut(row, family, qualifier, value, put);
-	}
-
-	@Override
-	public boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier,
-			CompareOp compareOp, byte[] value, Delete delete)
-			throws IOException {
-		return delegate.checkAndDelete(row, family, qualifier, compareOp, value, delete);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/b77bb9a9/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 1c91fe5..3444054 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
@@ -344,10 +344,8 @@ public class MutationState implements SQLCloseable {
         if (this == newMutationState) { // Doesn't make sense
             return;
         }
-        // TODO: what if new and old have txContext as that's really an error
-        // Really it's an error if newMutation txContext is not null
         if (txContext != null) {
-            for (TransactionAware txAware : txAwares) {
+            for (TransactionAware txAware : newMutationState.txAwares) {
                 txContext.addTransactionAware(txAware);
             }
         } else {
@@ -477,16 +475,16 @@ public class MutationState implements SQLCloseable {
         };
     }
 
-	private void generateMutations(final TableRef tableRef, long timestamp,
-			final Map<ImmutableBytesPtr, RowMutationState> values,
-			final List<Mutation> mutationList,
-			final List<Mutation> mutationsPertainingToIndex) {
-		final PTable table = tableRef.getTable();
+    private void generateMutations(final TableRef tableRef, long timestamp,
+            final Map<ImmutableBytesPtr, RowMutationState> values,
+            final List<Mutation> mutationList, final List<Mutation> mutationsPertainingToIndex) {
+        final PTable table = tableRef.getTable();
         boolean tableWithRowTimestampCol = table.getRowTimestampColPos() != -1;
-		Iterator<Map.Entry<ImmutableBytesPtr,RowMutationState>> iterator = values.entrySet().iterator();
-		long timestampToUse = timestamp;
+        Iterator<Map.Entry<ImmutableBytesPtr, RowMutationState>> iterator =
+                values.entrySet().iterator();
+        long timestampToUse = timestamp;
         while (iterator.hasNext()) {
-        	Map.Entry<ImmutableBytesPtr, RowMutationState> rowEntry = iterator.next();
+            Map.Entry<ImmutableBytesPtr, RowMutationState> rowEntry = iterator.next();
             ImmutableBytesPtr key = rowEntry.getKey();
             RowMutationState state = rowEntry.getValue();
             if (tableWithRowTimestampCol) {
@@ -500,26 +498,30 @@ public class MutationState implements SQLCloseable {
                     }
                 }
             }
-			PRow row = tableRef.getTable().newRow(connection.getKeyValueBuilder(), timestampToUse, key);
-			List<Mutation> rowMutations, rowMutationsPertainingToIndex;
-			if (rowEntry.getValue().getColumnValues() == PRow.DELETE_MARKER) { // means delete
-			    row.delete();
-			    rowMutations = row.toRowMutations();
-			    // Row deletes for index tables are processed by running a re-written query
-			    // against the index table (as this allows for flexibility in being able to
-			    // delete rows).
-			    rowMutationsPertainingToIndex = Collections.emptyList();
-			} else {
-				for (Map.Entry<PColumn,byte[]> valueEntry : rowEntry.getValue().getColumnValues().entrySet()) {
-			        row.setValue(valueEntry.getKey(), valueEntry.getValue());
-			    }
-			    rowMutations = row.toRowMutations();
-			    rowMutationsPertainingToIndex = rowMutations;
-			}
-			mutationList.addAll(rowMutations);
-			if (mutationsPertainingToIndex != null) mutationsPertainingToIndex.addAll(rowMutationsPertainingToIndex);
+            PRow row =
+                    tableRef.getTable()
+                            .newRow(connection.getKeyValueBuilder(), timestampToUse, key);
+            List<Mutation> rowMutations, rowMutationsPertainingToIndex;
+            if (rowEntry.getValue().getColumnValues() == PRow.DELETE_MARKER) { // means delete
+                row.delete();
+                rowMutations = row.toRowMutations();
+                // Row deletes for index tables are processed by running a re-written query
+                // against the index table (as this allows for flexibility in being able to
+                // delete rows).
+                rowMutationsPertainingToIndex = Collections.emptyList();
+            } else {
+                for (Map.Entry<PColumn, byte[]> valueEntry : rowEntry.getValue().getColumnValues()
+                        .entrySet()) {
+                    row.setValue(valueEntry.getKey(), valueEntry.getValue());
+                }
+                rowMutations = row.toRowMutations();
+                rowMutationsPertainingToIndex = rowMutations;
+            }
+            mutationList.addAll(rowMutations);
+            if (mutationsPertainingToIndex != null) mutationsPertainingToIndex
+                    .addAll(rowMutationsPertainingToIndex);
         }
-	}
+    }
     
     /**
      * Get the unsorted list of HBase mutations for the tables with uncommitted data.
@@ -658,7 +660,7 @@ public class MutationState implements SQLCloseable {
             }
         }
     }
-    private class MetaDataAwareHTable extends DelegateHTableInterface {
+    private class MetaDataAwareHTable extends DelegateHTable {
         private final TableRef tableRef;
         
         private MetaDataAwareHTable(HTableInterface delegate, TableRef tableRef) {
@@ -984,9 +986,11 @@ public class MutationState implements SQLCloseable {
                 } catch (TransactionFailureException e) {
                     try {
                         txContext.abort(e);
-                        throw new SQLExceptionInfo.Builder(SQLExceptionCode.TRANSACTION_FAILED).setRootCause(e).build().buildException();
+                        // abort and throw the original commit failure exception
+                        throw TransactionUtil.getTransactionFailureException(e);
                     } catch (TransactionFailureException e1) {
-                        throw TransactionUtil.getSQLException(e);
+                        // if abort fails and throw the abort failure exception
+                        throw TransactionUtil.getTransactionFailureException(e1);
                     }
                 } finally {
                   	if (!sendMutationsFailed) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/b77bb9a9/phoenix-core/src/main/java/org/apache/phoenix/util/TransactionUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/TransactionUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/TransactionUtil.java
index 175847d..9f16e52 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/TransactionUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/TransactionUtil.java
@@ -44,7 +44,7 @@ public class TransactionUtil {
         return serverTimeStamp / TxConstants.MAX_TX_PER_MS;
     }
     
-    public static SQLException getSQLException(TransactionFailureException e) {
+    public static SQLException getTransactionFailureException(TransactionFailureException e) {
         if (e instanceof TransactionConflictException) { 
             return new SQLExceptionInfo.Builder(SQLExceptionCode.TRANSACTION_CONFLICT_EXCEPTION)
                 .setMessage(e.getMessage())
@@ -52,7 +52,7 @@ public class TransactionUtil {
                 .build().buildException();
 
         }
-        return new SQLExceptionInfo.Builder(SQLExceptionCode.TRANSACTION_EXCEPTION)
+        return new SQLExceptionInfo.Builder(SQLExceptionCode.TRANSACTION_FAILED)
             .setMessage(e.getMessage())
             .setRootCause(e)
             .build().buildException();