You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by "Thomas D'Silva (JIRA)" <ji...@apache.org> on 2016/02/04 23:16:39 UTC
[jira] [Commented] (PHOENIX-2654) Add test for connection rollback
with external tx context set.
[ https://issues.apache.org/jira/browse/PHOENIX-2654?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15133162#comment-15133162 ]
Thomas D'Silva commented on PHOENIX-2654:
-----------------------------------------
[~gokulavasan]
Calling rollback on a connection with an external tx context set seems to work for me. Is this test similar to how you setup the connection?
{code}
@Test
public void testExternalTxContextWithRollback() throws Exception {
ResultSet rs;
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
conn.setAutoCommit(false);
PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class);
String fullTableName = "T";
HTableInterface htable = pconn.getQueryServices().getTable(Bytes.toBytes(fullTableName));
TransactionSystemClient txServiceClient = pconn.getQueryServices().getTransactionSystemClient();
TransactionAwareHTable txAware = new TransactionAwareHTable(htable, TxConstants.ConflictDetection.ROW);
TransactionContext txContext = new TransactionContext(txServiceClient, txAware);
txContext.start();
pconn.setTransactionContext(txContext);
Statement stmt = conn.createStatement();
stmt.execute("CREATE TABLE " + fullTableName + "(K VARCHAR PRIMARY KEY, V1 VARCHAR, V2 VARCHAR) TRANSACTIONAL=true");
stmt.executeUpdate("upsert into " + fullTableName + " values('x', 'a', 'b')");
// verify we can see our own writes
rs = conn.createStatement().executeQuery("select count(*) from " + fullTableName);
assertTrue(rs.next());
assertEquals(1, rs.getInt(1));
conn.rollback();
// should not see any rows
try (Connection newConn = DriverManager.getConnection(getUrl(), props)) {
rs = newConn.createStatement().executeQuery("select count(*) from " + fullTableName);
assertTrue(rs.next());
assertEquals(0, rs.getInt(1));
}
// Even using HBase APIs directly, we shouldn't find 'x' since a delete marker would have been
// written to hide it.
Result result = htable.get(new Get(Bytes.toBytes("x")));
assertTrue(result.isEmpty());
}
{code}
> Add test for connection rollback with external tx context set.
> --------------------------------------------------------------
>
> Key: PHOENIX-2654
> URL: https://issues.apache.org/jira/browse/PHOENIX-2654
> Project: Phoenix
> Issue Type: Test
> Reporter: Thomas D'Silva
> Assignee: Thomas D'Silva
> Fix For: 4.7.0
>
>
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)