You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ga...@apache.org on 2019/04/25 16:41:35 UTC
[hive] branch branch-2.3 updated: HIVE-21639 Spark test failed
since HIVE-10632 (Yuming Wang via Alan Gates)
This is an automated email from the ASF dual-hosted git repository.
gates pushed a commit to branch branch-2.3
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/branch-2.3 by this push:
new 6dcb306 HIVE-21639 Spark test failed since HIVE-10632 (Yuming Wang via Alan Gates)
6dcb306 is described below
commit 6dcb306c5c636206d4baf73aecc95e37d159a2b2
Author: Alan Gates <ga...@hortonworks.com>
AuthorDate: Wed Apr 24 19:12:52 2019 -0700
HIVE-21639 Spark test failed since HIVE-10632 (Yuming Wang via Alan Gates)
---
.../hive/hcatalog/streaming/TestStreaming.java | 4 +-
.../streaming/mutate/StreamingTestUtils.java | 4 +-
.../hive/metastore/TestHiveMetaStoreTxns.java | 4 +-
.../org/apache/hadoop/hive/ql/TestAcidOnTez.java | 5 +-
.../hive/ql/txn/compactor/TestCompactor.java | 4 +-
.../hadoop/hive/metastore/txn/TxnDbUtil.java | 29 +-
.../hadoop/hive/metastore/txn/TxnHandler.java | 2 +-
.../hadoop/hive/metastore/txn/TestTxnUtils.java | 7 +-
.../metastore/txn/TestCompactionTxnHandler.java | 4 +-
.../hadoop/hive/metastore/txn/TestTxnHandler.java | 4 +-
.../txn/TestTxnHandlerNoConnectionPool.java | 6 +-
.../org/apache/hadoop/hive/ql/TestTxnCommands.java | 9 +-
.../apache/hadoop/hive/ql/TestTxnCommands2.java | 5 +-
.../hadoop/hive/ql/lockmgr/TestDbTxnManager.java | 28 +-
.../hadoop/hive/ql/lockmgr/TestDbTxnManager2.java | 356 ++++++++++-----------
.../hive/ql/txn/compactor/CompactorTest.java | 2 +-
16 files changed, 234 insertions(+), 239 deletions(-)
diff --git a/hcatalog/streaming/src/test/org/apache/hive/hcatalog/streaming/TestStreaming.java b/hcatalog/streaming/src/test/org/apache/hive/hcatalog/streaming/TestStreaming.java
index 8ea58e6..2413ca3 100644
--- a/hcatalog/streaming/src/test/org/apache/hive/hcatalog/streaming/TestStreaming.java
+++ b/hcatalog/streaming/src/test/org/apache/hive/hcatalog/streaming/TestStreaming.java
@@ -203,8 +203,8 @@ public class TestStreaming {
//1) Start from a clean slate (metastore)
- TxnDbUtil.cleanDb();
- TxnDbUtil.prepDb();
+ TxnDbUtil.cleanDb(conf);
+ TxnDbUtil.prepDb(conf);
//2) obtain metastore clients
msClient = new HiveMetaStoreClient(conf);
diff --git a/hcatalog/streaming/src/test/org/apache/hive/hcatalog/streaming/mutate/StreamingTestUtils.java b/hcatalog/streaming/src/test/org/apache/hive/hcatalog/streaming/mutate/StreamingTestUtils.java
index 87a72b5..63690f9 100644
--- a/hcatalog/streaming/src/test/org/apache/hive/hcatalog/streaming/mutate/StreamingTestUtils.java
+++ b/hcatalog/streaming/src/test/org/apache/hive/hcatalog/streaming/mutate/StreamingTestUtils.java
@@ -66,8 +66,8 @@ public class StreamingTestUtils {
public void prepareTransactionDatabase(HiveConf conf) throws Exception {
TxnDbUtil.setConfValues(conf);
- TxnDbUtil.cleanDb();
- TxnDbUtil.prepDb();
+ TxnDbUtil.cleanDb(conf);
+ TxnDbUtil.prepDb(conf);
}
public IMetaStoreClient newMetaStoreClient(HiveConf conf) throws Exception {
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStoreTxns.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStoreTxns.java
index a0f18c6..aeaaf9b 100644
--- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStoreTxns.java
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStoreTxns.java
@@ -259,12 +259,12 @@ public class TestHiveMetaStoreTxns {
@Before
public void setUp() throws Exception {
- TxnDbUtil.prepDb();
+ TxnDbUtil.prepDb(conf);
client = new HiveMetaStoreClient(conf);
}
@After
public void tearDown() throws Exception {
- TxnDbUtil.cleanDb();
+ TxnDbUtil.cleanDb(conf);
}
}
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestAcidOnTez.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestAcidOnTez.java
index 2bf9871..334be92 100644
--- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestAcidOnTez.java
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestAcidOnTez.java
@@ -76,7 +76,6 @@ public class TestAcidOnTez {
@Before
public void setUp() throws Exception {
- tearDown();
hiveConf = new HiveConf(this.getClass());
hiveConf.set(HiveConf.ConfVars.PREEXECHOOKS.varname, "");
hiveConf.set(HiveConf.ConfVars.POSTEXECHOOKS.varname, "");
@@ -88,7 +87,7 @@ public class TestAcidOnTez {
.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER,
"org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
TxnDbUtil.setConfValues(hiveConf);
- TxnDbUtil.prepDb();
+ TxnDbUtil.prepDb(hiveConf);
File f = new File(TEST_WAREHOUSE_DIR);
if (f.exists()) {
FileUtil.fullyDelete(f);
@@ -133,7 +132,7 @@ public class TestAcidOnTez {
d.close();
d = null;
}
- TxnDbUtil.cleanDb();
+ TxnDbUtil.cleanDb(hiveConf);
} finally {
FileUtils.deleteDirectory(new File(TEST_DATA_DIR));
}
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/txn/compactor/TestCompactor.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/txn/compactor/TestCompactor.java
index 66ed8ca..3054918 100644
--- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/txn/compactor/TestCompactor.java
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/txn/compactor/TestCompactor.java
@@ -118,8 +118,8 @@ public class TestCompactor {
//"org.apache.hadoop.hive.ql.io.HiveInputFormat"
TxnDbUtil.setConfValues(hiveConf);
- TxnDbUtil.cleanDb();
- TxnDbUtil.prepDb();
+ TxnDbUtil.cleanDb(hiveConf);
+ TxnDbUtil.prepDb(hiveConf);
conf = hiveConf;
msClient = new HiveMetaStoreClient(conf);
diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnDbUtil.java b/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnDbUtil.java
index f72c379..3373145 100644
--- a/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnDbUtil.java
+++ b/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnDbUtil.java
@@ -61,7 +61,7 @@ public final class TxnDbUtil {
conf.setBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, true);
}
- public static void prepDb() throws Exception {
+ public static void prepDb(HiveConf conf) throws Exception {
// This is a bogus hack because it copies the contents of the SQL file
// intended for creating derby databases, and thus will inexorably get
// out of date with it. I'm open to any suggestions on how to make this
@@ -70,7 +70,7 @@ public final class TxnDbUtil {
Connection conn = null;
Statement stmt = null;
try {
- conn = getConnection();
+ conn = getConnection(conf);
stmt = conn.createStatement();
stmt.execute("CREATE TABLE TXNS (" +
" TXN_ID bigint PRIMARY KEY," +
@@ -174,7 +174,7 @@ public final class TxnDbUtil {
// This might be a deadlock, if so, let's retry
if (e instanceof SQLTransactionRollbackException && deadlockCnt++ < 5) {
LOG.warn("Caught deadlock, retrying db creation");
- prepDb();
+ prepDb(conf);
} else {
throw e;
}
@@ -184,14 +184,14 @@ public final class TxnDbUtil {
}
}
- public static void cleanDb() throws Exception {
+ public static void cleanDb(HiveConf conf) throws Exception {
int retryCount = 0;
while(++retryCount <= 3) {
boolean success = true;
Connection conn = null;
Statement stmt = null;
try {
- conn = getConnection();
+ conn = getConnection(conf);
stmt = conn.createStatement();
// We want to try these, whether they succeed or fail.
@@ -249,12 +249,12 @@ public final class TxnDbUtil {
*
* @return number of components, or 0 if there is no lock
*/
- public static int countLockComponents(long lockId) throws Exception {
+ public static int countLockComponents(HiveConf conf, long lockId) throws Exception {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
- conn = getConnection();
+ conn = getConnection(conf);
stmt = conn.prepareStatement("SELECT count(*) FROM hive_locks WHERE hl_lock_ext_id = ?");
stmt.setLong(1, lockId);
rs = stmt.executeQuery();
@@ -273,12 +273,12 @@ public final class TxnDbUtil {
* @return count countQuery result
* @throws Exception
*/
- public static int countQueryAgent(String countQuery) throws Exception {
+ public static int countQueryAgent(HiveConf conf, String countQuery) throws Exception {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
- conn = getConnection();
+ conn = getConnection(conf);
stmt = conn.createStatement();
rs = stmt.executeQuery(countQuery);
if (!rs.next()) {
@@ -290,16 +290,16 @@ public final class TxnDbUtil {
}
}
@VisibleForTesting
- public static String queryToString(String query) throws Exception {
- return queryToString(query, true);
+ public static String queryToString(HiveConf conf, String query) throws Exception {
+ return queryToString(conf, query, true);
}
- public static String queryToString(String query, boolean includeHeader) throws Exception {
+ public static String queryToString(HiveConf conf, String query, boolean includeHeader) throws Exception {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
StringBuilder sb = new StringBuilder();
try {
- conn = getConnection();
+ conn = getConnection(conf);
stmt = conn.createStatement();
rs = stmt.executeQuery(query);
ResultSetMetaData rsmd = rs.getMetaData();
@@ -321,8 +321,7 @@ public final class TxnDbUtil {
return sb.toString();
}
- static Connection getConnection() throws Exception {
- HiveConf conf = new HiveConf();
+ static Connection getConnection(HiveConf conf) throws Exception {
String jdbcDriver = HiveConf.getVar(conf, HiveConf.ConfVars.METASTORE_CONNECTION_DRIVER);
Driver driver = (Driver) Class.forName(jdbcDriver).newInstance();
Properties prop = new Properties();
diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java b/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
index 0e8253b..a310c27 100644
--- a/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
+++ b/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
@@ -2331,7 +2331,7 @@ abstract class TxnHandler implements TxnStore, TxnStore.MutexAPI {
// Set up the transaction/locking db in the derby metastore
TxnDbUtil.setConfValues(conf);
try {
- TxnDbUtil.prepDb();
+ TxnDbUtil.prepDb(conf);
} catch (Exception e) {
// We may have already created the tables and thus don't need to redo it.
if (e.getMessage() != null && !e.getMessage().contains("already exists")) {
diff --git a/metastore/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnUtils.java b/metastore/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnUtils.java
index 4c3b824..ec296d1 100644
--- a/metastore/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnUtils.java
+++ b/metastore/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnUtils.java
@@ -137,7 +137,7 @@ public class TestTxnUtils {
ResultSet rs = null;
try {
- conn = TxnDbUtil.getConnection();
+ conn = TxnDbUtil.getConnection(conf);
stmt = conn.createStatement();
for (String query : queries) {
rs = stmt.executeQuery(query);
@@ -201,14 +201,13 @@ public class TestTxnUtils {
@Before
public void setUp() throws Exception {
- tearDown();
conf = new HiveConf(this.getClass());
TxnDbUtil.setConfValues(conf);
- TxnDbUtil.prepDb();
+ TxnDbUtil.prepDb(conf);
}
@After
public void tearDown() throws Exception {
- TxnDbUtil.cleanDb();
+ TxnDbUtil.cleanDb(conf);
}
}
diff --git a/ql/src/test/org/apache/hadoop/hive/metastore/txn/TestCompactionTxnHandler.java b/ql/src/test/org/apache/hadoop/hive/metastore/txn/TestCompactionTxnHandler.java
index f8ae86b..96005b4 100644
--- a/ql/src/test/org/apache/hadoop/hive/metastore/txn/TestCompactionTxnHandler.java
+++ b/ql/src/test/org/apache/hadoop/hive/metastore/txn/TestCompactionTxnHandler.java
@@ -450,13 +450,13 @@ public class TestCompactionTxnHandler {
@Before
public void setUp() throws Exception {
- TxnDbUtil.prepDb();
+ TxnDbUtil.prepDb(conf);
txnHandler = TxnUtils.getTxnStore(conf);
}
@After
public void tearDown() throws Exception {
- TxnDbUtil.cleanDb();
+ TxnDbUtil.cleanDb(conf);
}
private long openTxn() throws MetaException {
diff --git a/ql/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnHandler.java b/ql/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnHandler.java
index adfe98a..a61bdb2 100644
--- a/ql/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnHandler.java
+++ b/ql/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnHandler.java
@@ -1543,13 +1543,13 @@ public class TestTxnHandler {
@Before
public void setUp() throws Exception {
- TxnDbUtil.prepDb();
+ TxnDbUtil.prepDb(conf);
txnHandler = TxnUtils.getTxnStore(conf);
}
@After
public void tearDown() throws Exception {
- TxnDbUtil.cleanDb();
+ TxnDbUtil.cleanDb(conf);
}
private long openTxn() throws MetaException {
diff --git a/ql/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnHandlerNoConnectionPool.java b/ql/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnHandlerNoConnectionPool.java
index e5f4dde..a9cf3df 100644
--- a/ql/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnHandlerNoConnectionPool.java
+++ b/ql/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnHandlerNoConnectionPool.java
@@ -50,18 +50,18 @@ public class TestTxnHandlerNoConnectionPool {
conf.setVar(HiveConf.ConfVars.METASTORE_CONNECTION_POOLING_TYPE, "None");
TxnDbUtil.setConfValues(conf);
try {
- TxnDbUtil.prepDb();
+ TxnDbUtil.prepDb(conf);
} catch (SQLException e) {
// Usually this means we've already created the tables, so clean them and then try again
tearDown();
- TxnDbUtil.prepDb();
+ TxnDbUtil.prepDb(conf);
}
txnHandler = TxnUtils.getTxnStore(conf);
}
@After
public void tearDown() throws Exception {
- TxnDbUtil.cleanDb();
+ TxnDbUtil.cleanDb(conf);
}
@Test
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands.java b/ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands.java
index c8bc119..077d8f9 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands.java
@@ -99,7 +99,6 @@ public class TestTxnCommands {
@Before
public void setUp() throws Exception {
- tearDown();
hiveConf = new HiveConf(this.getClass());
hiveConf.set(HiveConf.ConfVars.PREEXECHOOKS.varname, "");
hiveConf.set(HiveConf.ConfVars.POSTEXECHOOKS.varname, "");
@@ -110,7 +109,7 @@ public class TestTxnCommands {
"org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
hiveConf.setBoolVar(HiveConf.ConfVars.MERGE_CARDINALITY_VIOLATION_CHECK, true);
TxnDbUtil.setConfValues(hiveConf);
- TxnDbUtil.prepDb();
+ TxnDbUtil.prepDb(hiveConf);
File f = new File(TEST_WAREHOUSE_DIR);
if (f.exists()) {
FileUtil.fullyDelete(f);
@@ -144,7 +143,7 @@ public class TestTxnCommands {
d = null;
}
} finally {
- TxnDbUtil.cleanDb();
+ TxnDbUtil.cleanDb(hiveConf);
FileUtils.deleteDirectory(new File(TEST_DATA_DIR));
}
}
@@ -469,7 +468,7 @@ public class TestTxnCommands {
Assert.assertNotNull(txnInfo);
Assert.assertEquals(2, txnInfo.getId());
Assert.assertEquals(TxnState.OPEN, txnInfo.getState());
- String s =TxnDbUtil.queryToString("select TXN_STARTED, TXN_LAST_HEARTBEAT from TXNS where TXN_ID = " + txnInfo.getId(), false);
+ String s =TxnDbUtil.queryToString(hiveConf, "select TXN_STARTED, TXN_LAST_HEARTBEAT from TXNS where TXN_ID = " + txnInfo.getId(), false);
String[] vals = s.split("\\s+");
Assert.assertEquals("Didn't get expected timestamps", 2, vals.length);
long lastHeartbeat = Long.parseLong(vals[1]);
@@ -493,7 +492,7 @@ public class TestTxnCommands {
TestDbTxnManager2.checkLock(LockType.SHARED_READ, LockState.ACQUIRED, "default", Table.ACIDTBL.name, null, slr.getLocks());
//should've done several heartbeats
- s =TxnDbUtil.queryToString("select TXN_STARTED, TXN_LAST_HEARTBEAT from TXNS where TXN_ID = " + txnInfo.getId(), false);
+ s =TxnDbUtil.queryToString(hiveConf, "select TXN_STARTED, TXN_LAST_HEARTBEAT from TXNS where TXN_ID = " + txnInfo.getId(), false);
vals = s.split("\\s+");
Assert.assertEquals("Didn't get expected timestamps", 2, vals.length);
Assert.assertTrue("Heartbeat didn't progress: (old,new) (" + lastHeartbeat + "," + vals[1]+ ")",
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands2.java b/ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands2.java
index 267de21..8eb4d57 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands2.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands2.java
@@ -109,7 +109,6 @@ public class TestTxnCommands2 {
}
protected void setUpWithTableProperties(String tableProperties) throws Exception {
- tearDown();
hiveConf = new HiveConf(this.getClass());
hiveConf.set(HiveConf.ConfVars.PREEXECHOOKS.varname, "");
hiveConf.set(HiveConf.ConfVars.POSTEXECHOOKS.varname, "");
@@ -122,7 +121,7 @@ public class TestTxnCommands2 {
hiveConf.setBoolVar(HiveConf.ConfVars.MERGE_CARDINALITY_VIOLATION_CHECK, true);
TxnDbUtil.setConfValues(hiveConf);
- TxnDbUtil.prepDb();
+ TxnDbUtil.prepDb(hiveConf);
File f = new File(TEST_WAREHOUSE_DIR);
if (f.exists()) {
FileUtil.fullyDelete(f);
@@ -159,7 +158,7 @@ public class TestTxnCommands2 {
d.close();
d = null;
}
- TxnDbUtil.cleanDb();
+ TxnDbUtil.cleanDb(hiveConf);
} finally {
FileUtils.deleteDirectory(new File(TEST_DATA_DIR));
}
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager.java b/ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager.java
index 9bfc7d1..d788ecc 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager.java
@@ -84,7 +84,7 @@ public class TestDbTxnManager {
List<HiveLock> locks = ctx.getHiveLocks();
Assert.assertEquals(1, locks.size());
Assert.assertEquals(1,
- TxnDbUtil.countLockComponents(((DbLockManager.DbHiveLock) locks.get(0)).lockId));
+ TxnDbUtil.countLockComponents(conf, ((DbLockManager.DbHiveLock) locks.get(0)).lockId));
txnMgr.getLockManager().unlock(locks.get(0));
locks = txnMgr.getLockManager().getLocks(false, false);
Assert.assertEquals(0, locks.size());
@@ -98,7 +98,7 @@ public class TestDbTxnManager {
List<HiveLock> locks = ctx.getHiveLocks();
Assert.assertEquals(1, locks.size());
Assert.assertEquals(1,
- TxnDbUtil.countLockComponents(((DbLockManager.DbHiveLock) locks.get(0)).lockId));
+ TxnDbUtil.countLockComponents(conf, ((DbLockManager.DbHiveLock) locks.get(0)).lockId));
txnMgr.getLockManager().unlock(locks.get(0));
locks = txnMgr.getLockManager().getLocks(false, false);
Assert.assertEquals(0, locks.size());
@@ -116,7 +116,7 @@ public class TestDbTxnManager {
List<HiveLock> locks = ctx.getHiveLocks();
Assert.assertEquals(1, locks.size());
Assert.assertEquals(3,
- TxnDbUtil.countLockComponents(((DbLockManager.DbHiveLock) locks.get(0)).lockId));
+ TxnDbUtil.countLockComponents(conf, ((DbLockManager.DbHiveLock) locks.get(0)).lockId));
txnMgr.getLockManager().unlock(locks.get(0));
locks = txnMgr.getLockManager().getLocks(false, false);
Assert.assertEquals(0, locks.size());
@@ -134,7 +134,7 @@ public class TestDbTxnManager {
List<HiveLock> locks = ctx.getHiveLocks();
Assert.assertEquals(1, locks.size());
Assert.assertEquals(4,
- TxnDbUtil.countLockComponents(((DbLockManager.DbHiveLock) locks.get(0)).lockId));
+ TxnDbUtil.countLockComponents(conf, ((DbLockManager.DbHiveLock) locks.get(0)).lockId));
txnMgr.getLockManager().unlock(locks.get(0));
locks = txnMgr.getLockManager().getLocks(false, false);
Assert.assertEquals(0, locks.size());
@@ -149,7 +149,7 @@ public class TestDbTxnManager {
List<HiveLock> locks = ctx.getHiveLocks();
Assert.assertEquals(1, locks.size());
Assert.assertEquals(1,
- TxnDbUtil.countLockComponents(((DbLockManager.DbHiveLock) locks.get(0)).lockId));
+ TxnDbUtil.countLockComponents(conf, ((DbLockManager.DbHiveLock) locks.get(0)).lockId));
txnMgr.commitTxn();
locks = txnMgr.getLockManager().getLocks(false, false);
Assert.assertEquals(0, locks.size());
@@ -165,7 +165,7 @@ public class TestDbTxnManager {
List<HiveLock> locks = ctx.getHiveLocks();
Assert.assertEquals(1, locks.size());
Assert.assertEquals(1,
- TxnDbUtil.countLockComponents(((DbLockManager.DbHiveLock) locks.get(0)).lockId));
+ TxnDbUtil.countLockComponents(conf, ((DbLockManager.DbHiveLock) locks.get(0)).lockId));
txnMgr.commitTxn();
locks = txnMgr.getLockManager().getLocks(false, false);
Assert.assertEquals(0, locks.size());
@@ -300,7 +300,7 @@ public class TestDbTxnManager {
List<HiveLock> locks = ctx.getHiveLocks();
Assert.assertEquals(1, locks.size());
Assert.assertEquals(4,
- TxnDbUtil.countLockComponents(((DbLockManager.DbHiveLock) locks.get(0)).lockId));
+ TxnDbUtil.countLockComponents(conf, ((DbLockManager.DbHiveLock) locks.get(0)).lockId));
txnMgr.commitTxn();
locks = txnMgr.getLockManager().getLocks(false, false);
Assert.assertEquals(0, locks.size());
@@ -315,7 +315,7 @@ public class TestDbTxnManager {
List<HiveLock> locks = ctx.getHiveLocks();
Assert.assertEquals(1, locks.size());
Assert.assertEquals(1,
- TxnDbUtil.countLockComponents(((DbLockManager.DbHiveLock) locks.get(0)).lockId));
+ TxnDbUtil.countLockComponents(conf, ((DbLockManager.DbHiveLock) locks.get(0)).lockId));
txnMgr.commitTxn();
locks = txnMgr.getLockManager().getLocks(false, false);
Assert.assertEquals(0, locks.size());
@@ -330,7 +330,7 @@ public class TestDbTxnManager {
List<HiveLock> locks = ctx.getHiveLocks();
Assert.assertEquals(1, locks.size());
Assert.assertEquals(1,
- TxnDbUtil.countLockComponents(((DbLockManager.DbHiveLock) locks.get(0)).lockId));
+ TxnDbUtil.countLockComponents(conf, ((DbLockManager.DbHiveLock) locks.get(0)).lockId));
txnMgr.commitTxn();
locks = txnMgr.getLockManager().getLocks(false, false);
Assert.assertEquals(0, locks.size());
@@ -345,7 +345,7 @@ public class TestDbTxnManager {
List<HiveLock> locks = ctx.getHiveLocks();
Assert.assertEquals(1, locks.size());
Assert.assertEquals(1,
- TxnDbUtil.countLockComponents(((DbLockManager.DbHiveLock) locks.get(0)).lockId));
+ TxnDbUtil.countLockComponents(conf, ((DbLockManager.DbHiveLock) locks.get(0)).lockId));
txnMgr.rollbackTxn();
locks = txnMgr.getLockManager().getLocks(false, false);
Assert.assertEquals(0, locks.size());
@@ -359,7 +359,7 @@ public class TestDbTxnManager {
List<HiveLock> locks = ctx.getHiveLocks();
Assert.assertEquals(1, locks.size());
Assert.assertEquals(1,
- TxnDbUtil.countLockComponents(((DbLockManager.DbHiveLock) locks.get(0)).lockId));
+ TxnDbUtil.countLockComponents(conf, ((DbLockManager.DbHiveLock) locks.get(0)).lockId));
txnMgr.getLockManager().unlock(locks.get(0));
locks = txnMgr.getLockManager().getLocks(false, false);
Assert.assertEquals(0, locks.size());
@@ -373,7 +373,7 @@ public class TestDbTxnManager {
List<HiveLock> locks = ctx.getHiveLocks();
Assert.assertEquals(1, locks.size());
Assert.assertEquals(1,
- TxnDbUtil.countLockComponents(((DbLockManager.DbHiveLock) locks.get(0)).lockId));
+ TxnDbUtil.countLockComponents(conf, ((DbLockManager.DbHiveLock) locks.get(0)).lockId));
txnMgr.getLockManager().unlock(locks.get(0));
locks = txnMgr.getLockManager().getLocks(false, false);
Assert.assertEquals(0, locks.size());
@@ -469,7 +469,7 @@ public class TestDbTxnManager {
@Before
public void setUp() throws Exception {
- TxnDbUtil.prepDb();
+ TxnDbUtil.prepDb(conf);
txnMgr = TxnManagerFactory.getTxnManagerFactory().getTxnManager(conf);
txnMgr.getLockManager();//init lock manager
Assert.assertTrue(txnMgr instanceof DbTxnManager);
@@ -485,7 +485,7 @@ public class TestDbTxnManager {
public void tearDown() throws Exception {
if(houseKeeperService != null) houseKeeperService.stop();
if (txnMgr != null) txnMgr.closeTxnManager();
- TxnDbUtil.cleanDb();
+ TxnDbUtil.cleanDb(conf);
}
private static class MockQueryPlan extends QueryPlan {
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager2.java b/ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager2.java
index 7cae109..39932ba 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager2.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager2.java
@@ -84,8 +84,8 @@ public class TestDbTxnManager2 {
ctx = new Context(conf);
driver = new Driver(conf);
driver.init();
- TxnDbUtil.cleanDb();
- TxnDbUtil.prepDb();
+ TxnDbUtil.cleanDb(conf);
+ TxnDbUtil.prepDb(conf);
SessionState ss = SessionState.get();
ss.initTxnMgr(conf);
txnMgr = ss.getTxnMgr();
@@ -434,9 +434,9 @@ public class TestDbTxnManager2 {
checkCmdOnDriver(cpr);
cpr = driver.run("insert into temp.T13p partition (ds='tomorrow', hour='2') values (8, 8)");
checkCmdOnDriver(cpr);
- int count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE in ('t10', 't11')");
+ int count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE in ('t10', 't11')");
Assert.assertEquals(4, count);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE in ('t12p', 't13p')");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE in ('t12p', 't13p')");
Assert.assertEquals(4, count);
// Fail some inserts, so that we have records in TXN_COMPONENTS
@@ -449,132 +449,132 @@ public class TestDbTxnManager2 {
checkCmdOnDriver(cpr);
cpr = driver.run("insert into temp.T13p partition (ds='today', hour='1') values (12, 12)");
checkCmdOnDriver(cpr);
- count = TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where TC_DATABASE='temp' and TC_TABLE in ('t10', 't11', 't12p', 't13p')");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where TC_DATABASE='temp' and TC_TABLE in ('t10', 't11', 't12p', 't13p')");
Assert.assertEquals(4, count);
conf.setBoolVar(HiveConf.ConfVars.HIVETESTMODEROLLBACKTXN, false);
// Drop a table/partition; corresponding records in TXN_COMPONENTS and COMPLETED_TXN_COMPONENTS should disappear
- count = TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where TC_DATABASE='temp' and TC_TABLE='t10'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where TC_DATABASE='temp' and TC_TABLE='t10'");
Assert.assertEquals(1, count);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE='t10'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE='t10'");
Assert.assertEquals(2, count);
cpr = driver.run("drop table temp.T10");
checkCmdOnDriver(cpr);
- count = TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where TC_DATABASE='temp' and TC_TABLE='t10'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where TC_DATABASE='temp' and TC_TABLE='t10'");
Assert.assertEquals(0, count);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE='t10'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE='t10'");
Assert.assertEquals(0, count);
- count = TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where TC_DATABASE='temp' and TC_TABLE='t12p' and TC_PARTITION='ds=today/hour=1'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where TC_DATABASE='temp' and TC_TABLE='t12p' and TC_PARTITION='ds=today/hour=1'");
Assert.assertEquals(1, count);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE='t12p' and CTC_PARTITION='ds=today/hour=1'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE='t12p' and CTC_PARTITION='ds=today/hour=1'");
Assert.assertEquals(1, count);
cpr = driver.run("alter table temp.T12p drop partition (ds='today', hour='1')");
checkCmdOnDriver(cpr);
- count = TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where TC_DATABASE='temp' and TC_TABLE='t12p' and TC_PARTITION='ds=today/hour=1'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where TC_DATABASE='temp' and TC_TABLE='t12p' and TC_PARTITION='ds=today/hour=1'");
Assert.assertEquals(0, count);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE='t12p' and CTC_PARTITION='ds=today/hour=1'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE='t12p' and CTC_PARTITION='ds=today/hour=1'");
Assert.assertEquals(0, count);
// Successfully perform compaction on a table/partition, so that we have successful records in COMPLETED_COMPACTIONS
cpr = driver.run("alter table temp.T11 compact 'minor'");
checkCmdOnDriver(cpr);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t11' and CQ_STATE='i' and CQ_TYPE='i'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t11' and CQ_STATE='i' and CQ_TYPE='i'");
Assert.assertEquals(1, count);
org.apache.hadoop.hive.ql.TestTxnCommands2.runWorker(conf);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t11' and CQ_STATE='r' and CQ_TYPE='i'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t11' and CQ_STATE='r' and CQ_TYPE='i'");
Assert.assertEquals(1, count);
org.apache.hadoop.hive.ql.TestTxnCommands2.runCleaner(conf);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t11'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t11'");
Assert.assertEquals(0, count);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE='t11' and CC_STATE='s' and CC_TYPE='i'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE='t11' and CC_STATE='s' and CC_TYPE='i'");
Assert.assertEquals(1, count);
cpr = driver.run("alter table temp.T12p partition (ds='tomorrow', hour='2') compact 'minor'");
checkCmdOnDriver(cpr);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t12p' and CQ_PARTITION='ds=tomorrow/hour=2' and CQ_STATE='i' and CQ_TYPE='i'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t12p' and CQ_PARTITION='ds=tomorrow/hour=2' and CQ_STATE='i' and CQ_TYPE='i'");
Assert.assertEquals(1, count);
org.apache.hadoop.hive.ql.TestTxnCommands2.runWorker(conf);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t12p' and CQ_PARTITION='ds=tomorrow/hour=2' and CQ_STATE='r' and CQ_TYPE='i'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t12p' and CQ_PARTITION='ds=tomorrow/hour=2' and CQ_STATE='r' and CQ_TYPE='i'");
Assert.assertEquals(1, count);
org.apache.hadoop.hive.ql.TestTxnCommands2.runCleaner(conf);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t12p'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t12p'");
Assert.assertEquals(0, count);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE='t12p' and CC_STATE='s' and CC_TYPE='i'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE='t12p' and CC_STATE='s' and CC_TYPE='i'");
Assert.assertEquals(1, count);
// Fail compaction, so that we have failed records in COMPLETED_COMPACTIONS
conf.setBoolVar(HiveConf.ConfVars.HIVETESTMODEFAILCOMPACTION, true);
cpr = driver.run("alter table temp.T11 compact 'major'");
checkCmdOnDriver(cpr);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t11' and CQ_STATE='i' and CQ_TYPE='a'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t11' and CQ_STATE='i' and CQ_TYPE='a'");
Assert.assertEquals(1, count);
org.apache.hadoop.hive.ql.TestTxnCommands2.runWorker(conf); // will fail
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t11' and CQ_STATE='i' and CQ_TYPE='a'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t11' and CQ_STATE='i' and CQ_TYPE='a'");
Assert.assertEquals(0, count);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE='t11' and CC_STATE='f' and CC_TYPE='a'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE='t11' and CC_STATE='f' and CC_TYPE='a'");
Assert.assertEquals(1, count);
cpr = driver.run("alter table temp.T12p partition (ds='tomorrow', hour='2') compact 'major'");
checkCmdOnDriver(cpr);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t12p' and CQ_PARTITION='ds=tomorrow/hour=2' and CQ_STATE='i' and CQ_TYPE='a'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t12p' and CQ_PARTITION='ds=tomorrow/hour=2' and CQ_STATE='i' and CQ_TYPE='a'");
Assert.assertEquals(1, count);
org.apache.hadoop.hive.ql.TestTxnCommands2.runWorker(conf); // will fail
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t12p' and CQ_PARTITION='ds=tomorrow/hour=2' and CQ_STATE='i' and CQ_TYPE='a'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t12p' and CQ_PARTITION='ds=tomorrow/hour=2' and CQ_STATE='i' and CQ_TYPE='a'");
Assert.assertEquals(0, count);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE='t12p' and CC_STATE='f' and CC_TYPE='a'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE='t12p' and CC_STATE='f' and CC_TYPE='a'");
Assert.assertEquals(1, count);
conf.setBoolVar(HiveConf.ConfVars.HIVETESTMODEFAILCOMPACTION, false);
// Put 2 records into COMPACTION_QUEUE and do nothing
cpr = driver.run("alter table temp.T11 compact 'major'");
checkCmdOnDriver(cpr);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t11' and CQ_STATE='i' and CQ_TYPE='a'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t11' and CQ_STATE='i' and CQ_TYPE='a'");
Assert.assertEquals(1, count);
cpr = driver.run("alter table temp.T12p partition (ds='tomorrow', hour='2') compact 'major'");
checkCmdOnDriver(cpr);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t12p' and CQ_PARTITION='ds=tomorrow/hour=2' and CQ_STATE='i' and CQ_TYPE='a'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t12p' and CQ_PARTITION='ds=tomorrow/hour=2' and CQ_STATE='i' and CQ_TYPE='a'");
Assert.assertEquals(1, count);
// Drop a table/partition, corresponding records in COMPACTION_QUEUE and COMPLETED_COMPACTIONS should disappear
cpr = driver.run("drop table temp.T11");
checkCmdOnDriver(cpr);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t11'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t11'");
Assert.assertEquals(0, count);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE='t11'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE='t11'");
Assert.assertEquals(0, count);
cpr = driver.run("alter table temp.T12p drop partition (ds='tomorrow', hour='2')");
checkCmdOnDriver(cpr);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t12p'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t12p'");
Assert.assertEquals(0, count);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE='t12p'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE='t12p'");
Assert.assertEquals(0, count);
// Put 1 record into COMPACTION_QUEUE and do nothing
cpr = driver.run("alter table temp.T13p partition (ds='today', hour='1') compact 'major'");
checkCmdOnDriver(cpr);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t13p' and CQ_STATE='i' and CQ_TYPE='a'");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t13p' and CQ_STATE='i' and CQ_TYPE='a'");
Assert.assertEquals(1, count);
// Drop database, everything in all 4 meta tables should disappear
- count = TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where TC_DATABASE='temp' and TC_TABLE in ('t10', 't11', 't12p', 't13p')");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where TC_DATABASE='temp' and TC_TABLE in ('t10', 't11', 't12p', 't13p')");
Assert.assertEquals(1, count);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE in ('t10', 't11', 't12p', 't13p')");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE in ('t10', 't11', 't12p', 't13p')");
Assert.assertEquals(2, count);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE in ('t10', 't11', 't12p', 't13p')");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE in ('t10', 't11', 't12p', 't13p')");
Assert.assertEquals(1, count);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE in ('t10', 't11', 't12p', 't13p')");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE in ('t10', 't11', 't12p', 't13p')");
Assert.assertEquals(0, count);
cpr = driver.run("drop database if exists temp cascade");
checkCmdOnDriver(cpr);
- count = TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where TC_DATABASE='temp' and TC_TABLE in ('t10', 't11', 't12p', 't13p')");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where TC_DATABASE='temp' and TC_TABLE in ('t10', 't11', 't12p', 't13p')");
Assert.assertEquals(0, count);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE in ('t10', 't11', 't12p', 't13p')");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE in ('t10', 't11', 't12p', 't13p')");
Assert.assertEquals(0, count);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE in ('t10', 't11', 't12p', 't13p')");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE in ('t10', 't11', 't12p', 't13p')");
Assert.assertEquals(0, count);
- count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE in ('t10', 't11', 't12p', 't13p')");
+ count = TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE in ('t10', 't11', 't12p', 't13p')");
Assert.assertEquals(0, count);
}
@@ -943,7 +943,7 @@ public class TestDbTxnManager2 {
@Test
public void testWriteSetTracking4() throws Exception {
dropTable(new String[] {"TAB_PART", "TAB2"});
- Assert.assertEquals(0, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET"));
+ Assert.assertEquals(0, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET"));
CommandProcessorResponse cpr = driver.run("create table if not exists TAB_PART (a int, b int) " +
"partitioned by (p string) clustered by (a) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true')");
checkCmdOnDriver(cpr);
@@ -970,14 +970,14 @@ public class TestDbTxnManager2 {
checkLock(LockType.SHARED_READ, LockState.ACQUIRED, "default", "TAB_PART", null, locks);
checkLock(LockType.SHARED_WRITE, LockState.ACQUIRED, "default", "TAB2", null, locks);
//update stmt has p=blah, thus nothing is actually update and we generate empty dyn part list
- Assert.assertEquals(0, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET"));
+ Assert.assertEquals(0, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET"));
AddDynamicPartitions adp = new AddDynamicPartitions(txnMgr2.getCurrentTxnId(),
"default", "tab2", Collections.EMPTY_LIST);
adp.setOperationType(DataOperationType.UPDATE);
txnHandler.addDynamicPartitions(adp);
txnMgr2.commitTxn();
//Short Running updated nothing, so we expect 0 rows in WRITE_SET
- Assert.assertEquals( 0, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET"));
+ Assert.assertEquals( 0, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET"));
txnMgr2.openTxn(ctx, "T3");
checkCmdOnDriver(driver.compileAndRespond("update TAB2 set b = 7 where p = 'two'"));//pretend this partition exists
@@ -987,19 +987,19 @@ public class TestDbTxnManager2 {
checkLock(LockType.SHARED_READ, LockState.ACQUIRED, "default", "TAB_PART", null, locks);
checkLock(LockType.SHARED_WRITE, LockState.ACQUIRED, "default", "TAB2", null, locks);//since TAB2 is empty
//update stmt has p=blah, thus nothing is actually update and we generate empty dyn part list
- Assert.assertEquals(0, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET"));
+ Assert.assertEquals(0, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET"));
adp = new AddDynamicPartitions(txnMgr2.getCurrentTxnId(),
"default", "tab2", Collections.singletonList("p=two"));
adp.setOperationType(DataOperationType.UPDATE);
txnHandler.addDynamicPartitions(adp);//simulate partition update
txnMgr2.commitTxn();
- Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString("select * from WRITE_SET"),
- 1, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET"));
+ Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
+ 1, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET"));
AcidWriteSetService houseKeeper = new AcidWriteSetService();
TestTxnCommands2.runHouseKeeperService(houseKeeper, conf);
//since T3 overlaps with Long Running (still open) GC does nothing
- Assert.assertEquals(1, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET"));
+ Assert.assertEquals(1, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET"));
checkCmdOnDriver(driver.compileAndRespond("update TAB2 set b = 17 where a = 1"));//no rows match
txnMgr.acquireLocks(driver.getPlan(), ctx, "Long Running");
//so generate empty Dyn Part call
@@ -1012,7 +1012,7 @@ public class TestDbTxnManager2 {
locks = getLocks(txnMgr);
Assert.assertEquals("Unexpected lock count", 0, locks.size());
TestTxnCommands2.runHouseKeeperService(houseKeeper, conf);
- Assert.assertEquals(0, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET"));
+ Assert.assertEquals(0, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET"));
}
/**
* overlapping txns updating the same resource but 1st one rolls back; 2nd commits
@@ -1021,7 +1021,7 @@ public class TestDbTxnManager2 {
@Test
public void testWriteSetTracking5() throws Exception {
dropTable(new String[] {"TAB_PART"});
- Assert.assertEquals(0, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET"));
+ Assert.assertEquals(0, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET"));
CommandProcessorResponse cpr = driver.run("create table if not exists TAB_PART (a int, b int) " +
"partitioned by (p string) clustered by (a) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true')");
checkCmdOnDriver(cpr);
@@ -1047,9 +1047,9 @@ public class TestDbTxnManager2 {
Arrays.asList("p=blah"));
adp.setOperationType(DataOperationType.UPDATE);
txnHandler.addDynamicPartitions(adp);
- Assert.assertEquals(0, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET"));
+ Assert.assertEquals(0, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET"));
txnMgr2.commitTxn();//since conflicting txn rolled back, commit succeeds
- Assert.assertEquals(1, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET"));
+ Assert.assertEquals(1, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET"));
}
/**
* check that read query concurrent with txn works ok
@@ -1057,7 +1057,7 @@ public class TestDbTxnManager2 {
@Test
public void testWriteSetTracking6() throws Exception {
dropTable(new String[] {"TAB2"});
- Assert.assertEquals(0, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET"));
+ Assert.assertEquals(0, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET"));
CommandProcessorResponse cpr = driver.run("create table if not exists TAB2(a int, b int) clustered " +
"by (a) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true')");
checkCmdOnDriver(cpr);
@@ -1070,18 +1070,18 @@ public class TestDbTxnManager2 {
txnMgr2.openTxn(ctx, "Horton");
checkCmdOnDriver(driver.compileAndRespond("update TAB2 set b = 17 where a = 101"));
txnMgr2.acquireLocks(driver.getPlan(), ctx, "Horton");
- Assert.assertEquals(0, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET"));
+ Assert.assertEquals(0, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET"));
locks = getLocks(txnMgr);
Assert.assertEquals("Unexpected lock count", 2, locks.size());
checkLock(LockType.SHARED_READ, LockState.ACQUIRED, "default", "TAB2", null, locks);
checkLock(LockType.SHARED_WRITE, LockState.ACQUIRED, "default", "TAB2", null, locks);
txnMgr2.commitTxn();//no conflict
- Assert.assertEquals(1, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET"));
+ Assert.assertEquals(1, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET"));
locks = getLocks(txnMgr);
Assert.assertEquals("Unexpected lock count", 1, locks.size());
checkLock(LockType.SHARED_READ, LockState.ACQUIRED, "default", "TAB2", null, locks);
TestTxnCommands2.runHouseKeeperService(new AcidWriteSetService(), conf);
- Assert.assertEquals(0, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET"));
+ Assert.assertEquals(0, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET"));
}
/**
@@ -1091,7 +1091,7 @@ public class TestDbTxnManager2 {
@Test
public void testWriteSetTracking7() throws Exception {
dropTable(new String[] {"tab2", "TAB2"});
- Assert.assertEquals(0, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET"));
+ Assert.assertEquals(0, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET"));
CommandProcessorResponse cpr = driver.run("create table if not exists tab2 (a int, b int) " +
"partitioned by (p string) clustered by (a) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true')");
checkCmdOnDriver(cpr);
@@ -1133,13 +1133,13 @@ public class TestDbTxnManager2 {
txnMgr.commitTxn();//txnid:3
//now both txns concurrently updated TAB2 but different partitions.
- Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString("select * from WRITE_SET"),
- 1, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_partition='p=one' and ws_operation_type='u'"));
- Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString("select * from WRITE_SET"),
- 1, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_partition='p=two' and ws_operation_type='u'"));
+ Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
+ 1, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_partition='p=one' and ws_operation_type='u'"));
+ Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
+ 1, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_partition='p=two' and ws_operation_type='u'"));
//2 from txnid:1, 1 from txnid:2, 1 from txnid:3
- Assert.assertEquals("COMPLETED_TXN_COMPONENTS mismatch: " + TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"),
- 4, TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where ctc_table='tab2' and ctc_partition is not null"));
+ Assert.assertEquals("COMPLETED_TXN_COMPONENTS mismatch: " + TxnDbUtil.queryToString(conf, "select * from COMPLETED_TXN_COMPONENTS"),
+ 4, TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where ctc_table='tab2' and ctc_partition is not null"));
//================
//test with predicates such that partition pruning doesn't kick in
@@ -1185,13 +1185,13 @@ public class TestDbTxnManager2 {
txnHandler.addDynamicPartitions(adp);
txnMgr.commitTxn();//txnid:6
- Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString("select * from WRITE_SET"),
- 1, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_partition='p=one' and ws_operation_type='u' and ws_table='tab1'"));
- Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString("select * from WRITE_SET"),
- 1, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_partition='p=two' and ws_operation_type='u' and ws_table='tab1'"));
+ Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
+ 1, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_partition='p=one' and ws_operation_type='u' and ws_table='tab1'"));
+ Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
+ 1, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_partition='p=two' and ws_operation_type='u' and ws_table='tab1'"));
//2 from insert + 1 for each update stmt
- Assert.assertEquals("COMPLETED_TXN_COMPONENTS mismatch: " + TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"),
- 4, TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where ctc_table='tab1' and ctc_partition is not null"));
+ Assert.assertEquals("COMPLETED_TXN_COMPONENTS mismatch: " + TxnDbUtil.queryToString(conf, "select * from COMPLETED_TXN_COMPONENTS"),
+ 4, TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where ctc_table='tab1' and ctc_partition is not null"));
}
/**
* Concurrent updates with partition pruning predicate and w/o one
@@ -1240,12 +1240,12 @@ public class TestDbTxnManager2 {
txnHandler.addDynamicPartitions(adp);
txnMgr.commitTxn();//txnid:3
- Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString("select * from WRITE_SET"),
- 1, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_partition='p=one' and ws_operation_type='u' and ws_table='tab1'"));
- Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString("select * from WRITE_SET"),
- 1, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_partition='p=two' and ws_operation_type='u' and ws_table='tab1'"));
- Assert.assertEquals("COMPLETED_TXN_COMPONENTS mismatch: " + TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"),
- 4, TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where ctc_table='tab1' and ctc_partition is not null"));
+ Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
+ 1, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_partition='p=one' and ws_operation_type='u' and ws_table='tab1'"));
+ Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
+ 1, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_partition='p=two' and ws_operation_type='u' and ws_table='tab1'"));
+ Assert.assertEquals("COMPLETED_TXN_COMPONENTS mismatch: " + TxnDbUtil.queryToString(conf, "select * from COMPLETED_TXN_COMPONENTS"),
+ 4, TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where ctc_table='tab1' and ctc_partition is not null"));
}
/**
* Concurrent update/delete of different partitions - should pass
@@ -1294,18 +1294,18 @@ public class TestDbTxnManager2 {
txnHandler.addDynamicPartitions(adp);
txnMgr.commitTxn();//txnid:3
- Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"),
- 2, TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=1 and ctc_table='tab1'"));
- Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"),
- 1, TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=2 and ctc_table='tab1' and ctc_partition='p=one'"));
- Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"),
- 1, TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=3 and ctc_table='tab1' and ctc_partition='p=two'"));
- Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString("select * from WRITE_SET"),
- 1, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_partition='p=one' and ws_operation_type='u' and ws_table='tab1'"));
- Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString("select * from WRITE_SET"),
- 1, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_partition='p=two' and ws_operation_type='d' and ws_table='tab1'"));
- Assert.assertEquals("COMPLETED_TXN_COMPONENTS mismatch: " + TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"),
- 4, TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where ctc_table='tab1' and ctc_partition is not null"));
+ Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString(conf, "select * from COMPLETED_TXN_COMPONENTS"),
+ 2, TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=1 and ctc_table='tab1'"));
+ Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString(conf, "select * from COMPLETED_TXN_COMPONENTS"),
+ 1, TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=2 and ctc_table='tab1' and ctc_partition='p=one'"));
+ Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString(conf, "select * from COMPLETED_TXN_COMPONENTS"),
+ 1, TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=3 and ctc_table='tab1' and ctc_partition='p=two'"));
+ Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
+ 1, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_partition='p=one' and ws_operation_type='u' and ws_table='tab1'"));
+ Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
+ 1, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_partition='p=two' and ws_operation_type='d' and ws_table='tab1'"));
+ Assert.assertEquals("COMPLETED_TXN_COMPONENTS mismatch: " + TxnDbUtil.queryToString(conf, "select * from COMPLETED_TXN_COMPONENTS"),
+ 4, TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where ctc_table='tab1' and ctc_partition is not null"));
}
/**
* Concurrent update/delete of same partition - should fail to commit
@@ -1364,10 +1364,10 @@ public class TestDbTxnManager2 {
"Aborting [txnid:3,3] due to a write conflict on default/tab1/p=two committed by [txnid:2,3] d/u",
exception.getCause().getMessage());
- Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString("select * from WRITE_SET"),
- 1, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_partition='p=two' and ws_operation_type='u' and ws_table='tab1'"));
- Assert.assertEquals("COMPLETED_TXN_COMPONENTS mismatch: " + TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"),
- 3, TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where ctc_table='tab1' and ctc_partition is not null"));
+ Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
+ 1, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_partition='p=two' and ws_operation_type='u' and ws_table='tab1'"));
+ Assert.assertEquals("COMPLETED_TXN_COMPONENTS mismatch: " + TxnDbUtil.queryToString(conf, "select * from COMPLETED_TXN_COMPONENTS"),
+ 3, TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where ctc_table='tab1' and ctc_partition is not null"));
}
/**
* Concurrent delte/detele of same partition - should pass
@@ -1422,16 +1422,16 @@ public class TestDbTxnManager2 {
txnHandler.addDynamicPartitions(adp);
txnMgr.commitTxn();//txnid:3
- Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString("select * from WRITE_SET"),
- 1, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_partition='p=two' and ws_operation_type='d' and ws_table='tab1' and ws_txnid=2"));
- Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString("select * from WRITE_SET"),
- 1, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_partition='p=two' and ws_operation_type='d' and ws_table='tab1' and ws_txnid=3"));
- Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString("select * from WRITE_SET"),
- 1, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_partition='p=two' and ws_operation_type='d' and ws_table='tab1' and ws_txnid=2"));
- Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString("select * from WRITE_SET"),
- 1, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_partition='p=two' and ws_operation_type='d' and ws_table='tab1' and ws_txnid=3"));
- Assert.assertEquals("COMPLETED_TXN_COMPONENTS mismatch: " + TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"),
- 4, TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where ctc_table='tab1' and ctc_partition is not null"));
+ Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
+ 1, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_partition='p=two' and ws_operation_type='d' and ws_table='tab1' and ws_txnid=2"));
+ Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
+ 1, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_partition='p=two' and ws_operation_type='d' and ws_table='tab1' and ws_txnid=3"));
+ Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
+ 1, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_partition='p=two' and ws_operation_type='d' and ws_table='tab1' and ws_txnid=2"));
+ Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
+ 1, TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_partition='p=two' and ws_operation_type='d' and ws_table='tab1' and ws_txnid=3"));
+ Assert.assertEquals("COMPLETED_TXN_COMPONENTS mismatch: " + TxnDbUtil.queryToString(conf, "select * from COMPLETED_TXN_COMPONENTS"),
+ 4, TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where ctc_table='tab1' and ctc_partition is not null"));
}
@Test
public void testCompletedTxnComponents() throws Exception {
@@ -1444,11 +1444,11 @@ public class TestDbTxnManager2 {
checkCmdOnDriver(driver.run("insert into tab_not_acid2 values(1,1),(2,2)"));
//writing both acid and non-acid resources in the same txn
checkCmdOnDriver(driver.run("from tab_not_acid2 insert into tab1 partition(p='two')(a,b) select a,b insert into tab_not_acid2(a,b) select a,b "));//txnid:1
- Assert.assertEquals(TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"),
- 1, TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS"));
+ Assert.assertEquals(TxnDbUtil.queryToString(conf, "select * from COMPLETED_TXN_COMPONENTS"),
+ 1, TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS"));
//only expect transactional components to be in COMPLETED_TXN_COMPONENTS
- Assert.assertEquals(TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"),
- 1, TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=1 and ctc_table='tab1'"));
+ Assert.assertEquals(TxnDbUtil.queryToString(conf, "select * from COMPLETED_TXN_COMPONENTS"),
+ 1, TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=1 and ctc_table='tab1'"));
}
/**
@@ -1469,13 +1469,13 @@ public class TestDbTxnManager2 {
//writing both acid and non-acid resources in the same txn
//tab1 write is a dynamic partition insert
checkCmdOnDriver(driver.run("from tab_not_acid insert into tab1 partition(p)(a,b,p) select a,b,p insert into tab_not_acid(a,b) select a,b where p='two'"));//txnid:2
- Assert.assertEquals(TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"),
- 4, TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS"));
+ Assert.assertEquals(TxnDbUtil.queryToString(conf, "select * from COMPLETED_TXN_COMPONENTS"),
+ 4, TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS"));
//only expect transactional components to be in COMPLETED_TXN_COMPONENTS
- Assert.assertEquals(TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"),
- 2, TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=2"));
- Assert.assertEquals(TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"),
- 2, TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=2 and ctc_table='tab1'"));
+ Assert.assertEquals(TxnDbUtil.queryToString(conf, "select * from COMPLETED_TXN_COMPONENTS"),
+ 2, TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=2"));
+ Assert.assertEquals(TxnDbUtil.queryToString(conf, "select * from COMPLETED_TXN_COMPONENTS"),
+ 2, TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=2 and ctc_table='tab1'"));
}
//todo: Concurrent insert/update of same partition - should pass
@@ -1584,9 +1584,9 @@ public class TestDbTxnManager2 {
Assert.assertEquals(
"TXN_COMPONENTS mismatch(" + JavaUtils.txnIdToString(txnId1) + "): " +
- TxnDbUtil.queryToString("select * from TXN_COMPONENTS"),
+ TxnDbUtil.queryToString(conf, "select * from TXN_COMPONENTS"),
0,
- TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where tc_txnid=" + txnId1));
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where tc_txnid=" + txnId1));
//complete 1st txn
AddDynamicPartitions adp = new AddDynamicPartitions(txnId1, "default", "target",
Collections.singletonList("p=1/q=3"));//update clause
@@ -1602,39 +1602,39 @@ public class TestDbTxnManager2 {
txnHandler.addDynamicPartitions(adp);
Assert.assertEquals(
"TXN_COMPONENTS mismatch(" + JavaUtils.txnIdToString(txnId1) + "): " +
- TxnDbUtil.queryToString("select * from TXN_COMPONENTS"),
+ TxnDbUtil.queryToString(conf, "select * from TXN_COMPONENTS"),
1,
- TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where tc_txnid=" + txnId1 +
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where tc_txnid=" + txnId1 +
" and tc_operation_type='u'"));
Assert.assertEquals(
"TXN_COMPONENTS mismatch(" + JavaUtils.txnIdToString(txnId1) + "): " +
- TxnDbUtil.queryToString("select * from TXN_COMPONENTS"),
+ TxnDbUtil.queryToString(conf, "select * from TXN_COMPONENTS"),
2,
- TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where tc_txnid=" + txnId1 +
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where tc_txnid=" + txnId1 +
" and tc_operation_type='d'"));
Assert.assertEquals(
"TXN_COMPONENTS mismatch(" + JavaUtils.txnIdToString(txnId1) + "): " +
- TxnDbUtil.queryToString("select * from TXN_COMPONENTS"),
+ TxnDbUtil.queryToString(conf, "select * from TXN_COMPONENTS"),
3,
- TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where tc_txnid=" + txnId1 +
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where tc_txnid=" + txnId1 +
" and tc_operation_type='i'"));
txnMgr.commitTxn();//commit T1
Assert.assertEquals(
"COMPLETED_TXN_COMPONENTS mismatch(" + JavaUtils.txnIdToString(txnId1) + "): " +
- TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"),
+ TxnDbUtil.queryToString(conf, "select * from COMPLETED_TXN_COMPONENTS"),
6,
- TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=" + txnId1));
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=" + txnId1));
Assert.assertEquals(
"WRITE_SET mismatch(" + JavaUtils.txnIdToString(txnId1) + "): " +
- TxnDbUtil.queryToString("select * from WRITE_SET"),
+ TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
1,
- TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_txnid=" + txnId1 +
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_txnid=" + txnId1 +
" and ws_operation_type='u'"));
Assert.assertEquals(
"WRITE_SET mismatch(" + JavaUtils.txnIdToString(txnId1) + "): " +
- TxnDbUtil.queryToString("select * from WRITE_SET"),
+ TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
2,
- TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_txnid=" + txnId1 +
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_txnid=" + txnId1 +
" and ws_operation_type='d'"));
//re-check locks which were in Waiting state - should now be Acquired
@@ -1649,9 +1649,9 @@ public class TestDbTxnManager2 {
Assert.assertEquals(
"TXN_COMPONENTS mismatch(" + JavaUtils.txnIdToString(txnId2) + "): " +
- TxnDbUtil.queryToString("select * from TXN_COMPONENTS"),
+ TxnDbUtil.queryToString(conf, "select * from TXN_COMPONENTS"),
0,
- TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where tc_txnid=" + txnId2));
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where tc_txnid=" + txnId2));
//complete 2nd txn
adp = new AddDynamicPartitions(txnId2, "default", "target",
Collections.singletonList(cc ? "p=1/q=3" : "p=1/p=2"));//update clause
@@ -1667,21 +1667,21 @@ public class TestDbTxnManager2 {
txnHandler.addDynamicPartitions(adp);
Assert.assertEquals(
"TXN_COMPONENTS mismatch(" + JavaUtils.txnIdToString(txnId2) + "): " +
- TxnDbUtil.queryToString("select * from TXN_COMPONENTS"),
+ TxnDbUtil.queryToString(conf, "select * from TXN_COMPONENTS"),
1,
- TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where tc_txnid=" + txnId2 +
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where tc_txnid=" + txnId2 +
" and tc_operation_type='u'"));
Assert.assertEquals(
"TXN_COMPONENTS mismatch(" + JavaUtils.txnIdToString(txnId2) + "): " +
- TxnDbUtil.queryToString("select * from TXN_COMPONENTS"),
+ TxnDbUtil.queryToString(conf, "select * from TXN_COMPONENTS"),
2,
- TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where tc_txnid=" + txnId2 +
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where tc_txnid=" + txnId2 +
" and tc_operation_type='d'"));
Assert.assertEquals(
"TXN_COMPONENTS mismatch(" + JavaUtils.txnIdToString(txnId2) + "): " +
- TxnDbUtil.queryToString("select * from TXN_COMPONENTS"),
+ TxnDbUtil.queryToString(conf, "select * from TXN_COMPONENTS"),
3,
- TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where tc_txnid=" + txnId2 +
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where tc_txnid=" + txnId2 +
" and tc_operation_type='i'"));
LockException expectedException = null;
@@ -1698,33 +1698,33 @@ public class TestDbTxnManager2 {
"committed by [txnid:2,3] u/u", expectedException.getMessage());
Assert.assertEquals(
"COMPLETED_TXN_COMPONENTS mismatch(" + JavaUtils.txnIdToString(txnId2) + "): " +
- TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"),
+ TxnDbUtil.queryToString(conf, "select * from COMPLETED_TXN_COMPONENTS"),
0,
- TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=" + txnId2));
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=" + txnId2));
Assert.assertEquals(
"WRITE_SET mismatch(" + JavaUtils.txnIdToString(txnId2) + "): " +
- TxnDbUtil.queryToString("select * from WRITE_SET"),
+ TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
0,
- TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_txnid=" + txnId2));
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_txnid=" + txnId2));
}
else {
Assert.assertNull("Unexpected exception " + expectedException, expectedException);
Assert.assertEquals(
"COMPLETED_TXN_COMPONENTS mismatch(" + JavaUtils.txnIdToString(txnId2) + "): " +
- TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"),
+ TxnDbUtil.queryToString(conf, "select * from COMPLETED_TXN_COMPONENTS"),
6,
- TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=" + txnId2));
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=" + txnId2));
Assert.assertEquals(
"WRITE_SET mismatch(" + JavaUtils.txnIdToString(txnId2) + "): " +
- TxnDbUtil.queryToString("select * from WRITE_SET"),
+ TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
1,
- TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_txnid=" + txnId2 +
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_txnid=" + txnId2 +
" and ws_operation_type='u'"));
Assert.assertEquals(
"WRITE_SET mismatch(" + JavaUtils.txnIdToString(txnId2) + "): " +
- TxnDbUtil.queryToString("select * from WRITE_SET"),
+ TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
2,
- TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_txnid=" + txnId2 +
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_txnid=" + txnId2 +
" and ws_operation_type='d'"));
}
@@ -1764,9 +1764,9 @@ public class TestDbTxnManager2 {
txnMgr.acquireLocks(driver.getPlan(), ctx, "T1");
Assert.assertEquals(
"TXN_COMPONENTS mismatch(" + JavaUtils.txnIdToString(txnid1) + "): " +
- TxnDbUtil.queryToString("select * from TXN_COMPONENTS"),
+ TxnDbUtil.queryToString(conf, "select * from TXN_COMPONENTS"),
1,//no DP, so it's populated from lock info
- TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where tc_txnid=" + txnid1));
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where tc_txnid=" + txnid1));
List<ShowLocksResponseElement> locks = getLocks(txnMgr);
Assert.assertEquals("Unexpected lock count", 1, locks.size());
@@ -1793,9 +1793,9 @@ public class TestDbTxnManager2 {
txnMgr.commitTxn();//commit T1
Assert.assertEquals("WRITE_SET mismatch(" + JavaUtils.txnIdToString(txnid1) + "): " +
- TxnDbUtil.queryToString("select * from WRITE_SET"),
+ TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
causeConflict ? 1 : 0,//Inserts are not tracked by WRITE_SET
- TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_txnid=" + txnid1 +
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_txnid=" + txnid1 +
" and ws_operation_type=" + (causeConflict ? "'u'" : "'i'")));
@@ -1808,14 +1808,14 @@ public class TestDbTxnManager2 {
Assert.assertEquals(
"TXN_COMPONENTS mismatch(" + JavaUtils.txnIdToString(txnid2) + "): " +
- TxnDbUtil.queryToString("select * from TXN_COMPONENTS"),
+ TxnDbUtil.queryToString(conf, "select * from TXN_COMPONENTS"),
1,//
- TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where tc_txnid=" + txnid2));
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where tc_txnid=" + txnid2));
Assert.assertEquals(
"TXN_COMPONENTS mismatch(" + JavaUtils.txnIdToString(txnid2) + "): " +
- TxnDbUtil.queryToString("select * from TXN_COMPONENTS"),
+ TxnDbUtil.queryToString(conf, "select * from TXN_COMPONENTS"),
1,//
- TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where tc_txnid=" + txnid2 +
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where tc_txnid=" + txnid2 +
"and tc_operation_type='d'"));
//complete T2 txn
@@ -1835,9 +1835,9 @@ public class TestDbTxnManager2 {
}
else {
Assert.assertEquals("WRITE_SET mismatch(" + JavaUtils.txnIdToString(txnid1) + "): " +
- TxnDbUtil.queryToString("select * from WRITE_SET"),
+ TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
1,//Unpartitioned table: 1 row for Delete; Inserts are not tracked in WRITE_SET
- TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_txnid=" + txnid2 +
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_txnid=" + txnid2 +
" and ws_operation_type='d'"));
}
}
@@ -1860,15 +1860,15 @@ public class TestDbTxnManager2 {
checkLock(LockType.SHARED_READ, LockState.ACQUIRED, "default", "target", null, locks);
Assert.assertEquals(
"HIVE_LOCKS mismatch(" + JavaUtils.txnIdToString(txnid1) + "): " +
- TxnDbUtil.queryToString("select * from HIVE_LOCKS"),
+ TxnDbUtil.queryToString(conf, "select * from HIVE_LOCKS"),
1,
- TxnDbUtil.countQueryAgent("select count(*) from HIVE_LOCKS where hl_txnid=" + txnid1));
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from HIVE_LOCKS where hl_txnid=" + txnid1));
txnMgr.rollbackTxn();
Assert.assertEquals(
"TXN_COMPONENTS mismatch(" + JavaUtils.txnIdToString(txnid1) + "): " +
- TxnDbUtil.queryToString("select * from TXN_COMPONENTS"),
+ TxnDbUtil.queryToString(conf, "select * from TXN_COMPONENTS"),
0,
- TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where tc_txnid=" + txnid1));
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where tc_txnid=" + txnid1));
//now actually write to table to generate some partitions
checkCmdOnDriver(driver.run("insert into target partition(p=1,q) values (1,2,2), (3,4,2), (5,6,3), (7,8,2)"));
driver.run("select count(*) from target");
@@ -1877,10 +1877,10 @@ public class TestDbTxnManager2 {
Assert.assertEquals("", "4", r.get(0));
Assert.assertEquals(//look in COMPLETED_TXN_COMPONENTS because driver.run() committed!!!!
"COMPLETED_TXN_COMPONENTS mismatch(" + JavaUtils.txnIdToString(txnid1 + 1) + "): " +
- TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"),
+ TxnDbUtil.queryToString(conf, "select * from COMPLETED_TXN_COMPONENTS"),
2,//2 distinct partitions created
//txnid+1 because we want txn used by previous driver.run("insert....)
- TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=" + (txnid1 + 1)));
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=" + (txnid1 + 1)));
long txnid2 = txnMgr.openTxn(ctx, "T1");
@@ -1895,9 +1895,9 @@ public class TestDbTxnManager2 {
txnHandler.addDynamicPartitions(adp);
Assert.assertEquals(
"TXN_COMPONENTS mismatch(" + JavaUtils.txnIdToString(txnid2) + "): " +
- TxnDbUtil.queryToString("select * from TXN_COMPONENTS"),
+ TxnDbUtil.queryToString(conf, "select * from TXN_COMPONENTS"),
2,//2 distinct partitions modified
- TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where tc_txnid=" + txnid2));
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where tc_txnid=" + txnid2));
txnMgr.commitTxn();
}
@Test
@@ -1958,9 +1958,9 @@ public class TestDbTxnManager2 {
Assert.assertEquals(
"TXN_COMPONENTS mismatch(" + JavaUtils.txnIdToString(txnId1) + "): " +
- TxnDbUtil.queryToString("select * from TXN_COMPONENTS"),
+ TxnDbUtil.queryToString(conf, "select * from TXN_COMPONENTS"),
0,//because it's using a DP write
- TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where tc_txnid=" + txnId1));
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where tc_txnid=" + txnId1));
//complete T1 transaction (simulate writing to 2 partitions)
AddDynamicPartitions adp = new AddDynamicPartitions(txnId1, "default", "target",
Arrays.asList("p=1/q=2","p=1/q=3"));
@@ -1968,15 +1968,15 @@ public class TestDbTxnManager2 {
txnHandler.addDynamicPartitions(adp);
Assert.assertEquals(
"TXN_COMPONENTS mismatch(" + JavaUtils.txnIdToString(txnId1) + "): " +
- TxnDbUtil.queryToString("select * from TXN_COMPONENTS"),
+ TxnDbUtil.queryToString(conf, "select * from TXN_COMPONENTS"),
2,
- TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where tc_txnid=" + txnId1 +
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where tc_txnid=" + txnId1 +
" and tc_operation_type='u'"));
txnMgr.commitTxn();//commit T1
Assert.assertEquals("WRITE_SET mismatch(" + JavaUtils.txnIdToString(txnId1) + "): " +
- TxnDbUtil.queryToString("select * from WRITE_SET"),
+ TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
2,//2 partitions updated
- TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_txnid=" + txnId1 +
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_txnid=" + txnId1 +
" and ws_operation_type='u'"));
@@ -1993,9 +1993,9 @@ public class TestDbTxnManager2 {
Assert.assertEquals(
"TXN_COMPONENTS mismatch(" + JavaUtils.txnIdToString(txnid2) + "): " +
- TxnDbUtil.queryToString("select * from TXN_COMPONENTS"),
+ TxnDbUtil.queryToString(conf, "select * from TXN_COMPONENTS"),
0,//because it's using a DP write
- TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where tc_txnid=" + txnid2));
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where tc_txnid=" + txnid2));
//complete T2 txn
//simulate Insert into 2 partitions
adp = new AddDynamicPartitions(txnid2, "default", "target",
@@ -2004,9 +2004,9 @@ public class TestDbTxnManager2 {
txnHandler.addDynamicPartitions(adp);
Assert.assertEquals(
"TXN_COMPONENTS mismatch(" + JavaUtils.txnIdToString(txnid2) + "): " +
- TxnDbUtil.queryToString("select * from TXN_COMPONENTS"),
+ TxnDbUtil.queryToString(conf, "select * from TXN_COMPONENTS"),
2,
- TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where tc_txnid=" + txnid2 + " and tc_operation_type='i'"));
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where tc_txnid=" + txnid2 + " and tc_operation_type='i'"));
//simulate Update of 1 partitions; depending on causeConflict, choose one of the partitions
//which was modified by the T1 update stmt or choose a non-conflicting one
adp = new AddDynamicPartitions(txnid2, "default", "target",
@@ -2015,9 +2015,9 @@ public class TestDbTxnManager2 {
txnHandler.addDynamicPartitions(adp);
Assert.assertEquals(
"TXN_COMPONENTS mismatch(" + JavaUtils.txnIdToString(txnid2) + "): " +
- TxnDbUtil.queryToString("select * from TXN_COMPONENTS"),
+ TxnDbUtil.queryToString(conf, "select * from TXN_COMPONENTS"),
1,
- TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where tc_txnid=" + txnid2 + " and tc_operation_type='u'"));
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from TXN_COMPONENTS where tc_txnid=" + txnid2 + " and tc_operation_type='u'"));
LockException expectedException = null;
@@ -2036,14 +2036,14 @@ public class TestDbTxnManager2 {
}
else {
Assert.assertEquals("WRITE_SET mismatch(" + JavaUtils.txnIdToString(txnid2) + "): " +
- TxnDbUtil.queryToString("select * from WRITE_SET"),
+ TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
1,//1 partitions updated
- TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_txnid=" + txnid2 +
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_txnid=" + txnid2 +
" and ws_operation_type='u'"));
Assert.assertEquals("WRITE_SET mismatch(" + JavaUtils.txnIdToString(txnid2) + "): " +
- TxnDbUtil.queryToString("select * from WRITE_SET"),
+ TxnDbUtil.queryToString(conf, "select * from WRITE_SET"),
1,//1 partitions updated (and no other entries)
- TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_txnid=" + txnid2));
+ TxnDbUtil.countQueryAgent(conf, "select count(*) from WRITE_SET where ws_txnid=" + txnid2));
}
}
@Test
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/CompactorTest.java b/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/CompactorTest.java
index bbed591..263b2bd 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/CompactorTest.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/CompactorTest.java
@@ -95,7 +95,7 @@ public abstract class CompactorTest {
protected CompactorTest() throws Exception {
conf = new HiveConf();
TxnDbUtil.setConfValues(conf);
- TxnDbUtil.cleanDb();
+ TxnDbUtil.cleanDb(conf);
ms = new HiveMetaStoreClient(conf);
txnHandler = TxnUtils.getTxnStore(conf);
tmpdir = new File (Files.createTempDirectory("compactor_test_table_").toString());