diff --git a/config/workload_all_conn_mngr.xml b/config/workload_all_conn_mngr.xml
new file mode 100644
index 0000000..142e0ce
--- /dev/null
+++ b/config/workload_all_conn_mngr.xml
@@ -0,0 +1,59 @@
+
+
+ yugabyte
+ com.yugabyte.Driver
+ 5433
+ yugabyte
+ yugabyte
+
+ TRANSACTION_REPEATABLE_READ
+
+
+
+
+
+ false
+ false
+
+ 128
+ true
+ true
+ true
+ 180000
+ true
+ false
+ false
+
+
+
+ NewOrder
+ 45
+
+
+ Payment
+ 43
+
+
+ OrderStatus
+ 4
+
+
+ Delivery
+ 4
+
+
+ StockLevel
+ 4
+
+
+
+ 1800
+ 10000
+
+ 2
+ 2
+
+
diff --git a/config/workload_all_conn_newConn_everyTxn.xml b/config/workload_all_conn_newConn_everyTxn.xml
new file mode 100644
index 0000000..ed5ffa3
--- /dev/null
+++ b/config/workload_all_conn_newConn_everyTxn.xml
@@ -0,0 +1,59 @@
+
+
+ yugabyte
+ com.yugabyte.Driver
+ 5433
+ yugabyte
+ yugabyte
+
+ TRANSACTION_REPEATABLE_READ
+
+
+
+
+
+ false
+ true
+
+ 128
+ true
+ true
+ true
+ 180000
+ true
+ false
+ false
+
+
+
+ NewOrder
+ 45
+
+
+ Payment
+ 43
+
+
+ OrderStatus
+ 4
+
+
+ Delivery
+ 4
+
+
+ StockLevel
+ 4
+
+
+
+ 1800
+ 10000
+
+ 2
+ 2
+
+
diff --git a/src/com/oltpbenchmark/ConfigFileOptions.java b/src/com/oltpbenchmark/ConfigFileOptions.java
index 934c1f6..e0e9bef 100644
--- a/src/com/oltpbenchmark/ConfigFileOptions.java
+++ b/src/com/oltpbenchmark/ConfigFileOptions.java
@@ -53,6 +53,14 @@ public Optional getUseThinkTime() {
return getBoolOpt("useThinkTime");
}
+ public Optional getUseHikariPool() {
+ return getBoolOpt("useHikariPool");
+ }
+
+ public Optional getCreateConnForEveryTx() {
+ return getBoolOpt("createConnForEveryTx");
+ }
+
public Optional getEnableForeignKeysAfterLoad() {
return getBoolOpt("enableForeignKeysAfterLoad");
}
diff --git a/src/com/oltpbenchmark/DBWorkload.java b/src/com/oltpbenchmark/DBWorkload.java
index e5005d3..7dea1d9 100644
--- a/src/com/oltpbenchmark/DBWorkload.java
+++ b/src/com/oltpbenchmark/DBWorkload.java
@@ -188,6 +188,8 @@ public static void main(String[] args) throws Exception {
wrkld.setShouldEnableForeignKeys(false);
}
+ configOptions.getUseHikariPool().ifPresent(wrkld::setUseHikariPool);
+ configOptions.getCreateConnForEveryTx().ifPresent(wrkld::setUseCreateConnForEveryTx);
configOptions.getBatchSize().ifPresent(wrkld::setBatchSize);
configOptions.getMaxRetriesPerTransaction().ifPresent(wrkld::setMaxRetriesPerTransaction);
configOptions.getMaxLoaderRetries().ifPresent(wrkld::setMaxLoaderRetries);
diff --git a/src/com/oltpbenchmark/ThreadBench.java b/src/com/oltpbenchmark/ThreadBench.java
index fa8b87c..393df36 100644
--- a/src/com/oltpbenchmark/ThreadBench.java
+++ b/src/com/oltpbenchmark/ThreadBench.java
@@ -208,6 +208,7 @@ private int finalizeWorkers(ArrayList workerThreads) throws InterruptedE
*/
requests += w.getRequests();
+ w.closeConnection();
}
testState = null;
return requests;
diff --git a/src/com/oltpbenchmark/WorkloadConfiguration.java b/src/com/oltpbenchmark/WorkloadConfiguration.java
index 1556118..0eb2be3 100644
--- a/src/com/oltpbenchmark/WorkloadConfiguration.java
+++ b/src/com/oltpbenchmark/WorkloadConfiguration.java
@@ -68,6 +68,8 @@ public void setBenchmarkName(String benchmarkName) {
private boolean useStoredProcedures = true;
private int maxRetriesPerTransaction = 0;
private int maxLoaderRetries = 0;
+ private boolean useHikariPool = true;
+ private boolean useCreateConnForEveryTx = false;
public TraceReader getTraceReader() {
return traceReader;
@@ -361,6 +363,16 @@ public void setMaxRetriesPerTransaction(int maxRetriesPerTransaction) {
this.maxRetriesPerTransaction = maxRetriesPerTransaction;
}
+ public void setUseHikariPool(boolean useHikariPool) {
+ this.useHikariPool = useHikariPool;
+ }
+ public boolean getUseHikariPool() { return this.useHikariPool; }
+
+ public void setUseCreateConnForEveryTx(boolean useCreateConnForEveryTx) {
+ this.useCreateConnForEveryTx = useCreateConnForEveryTx;
+ }
+ public boolean getUseCreateConnForEveryTx() { return this.useCreateConnForEveryTx; }
+
public int getMaxRetriesPerTransaction() {
return maxRetriesPerTransaction;
}
diff --git a/src/com/oltpbenchmark/api/BenchmarkModule.java b/src/com/oltpbenchmark/api/BenchmarkModule.java
index d5d3a44..d7c5514 100644
--- a/src/com/oltpbenchmark/api/BenchmarkModule.java
+++ b/src/com/oltpbenchmark/api/BenchmarkModule.java
@@ -71,7 +71,10 @@ public BenchmarkModule(WorkloadConfiguration workConf) {
this.workConf = workConf;
if (workConf.getNeedsExecution()) {
try {
- createDataSource();
+ if(workConf.getUseHikariPool())
+ createDataSource();
+ else
+ LOG.info("Hikari Connection Pool is disabled");
} catch (Exception e) {
LOG.error("Failed to create Data source", e);
throw e;
diff --git a/src/com/oltpbenchmark/api/Worker.java b/src/com/oltpbenchmark/api/Worker.java
index c2d50a3..58451a0 100644
--- a/src/com/oltpbenchmark/api/Worker.java
+++ b/src/com/oltpbenchmark/api/Worker.java
@@ -57,6 +57,7 @@ public class Worker implements Runnable {
// Interval requests used by the monitor
private final AtomicInteger intervalRequests = new AtomicInteger(0);
+ private final Connection ll_conn;
private final int id;
private final BenchmarkModule benchmarkModule;
protected final HikariDataSource dataSource;
@@ -81,7 +82,13 @@ public Worker(
assert (this.transactionTypes != null) : "The TransactionTypes from the WorkloadConfiguration is null!";
try {
- this.dataSource = this.benchmarkModule.getDataSource();
+ if(!wrkld.getUseHikariPool()) {
+ this.dataSource = null;
+ ll_conn = wrkld.getUseCreateConnForEveryTx() ? null : benchmarkModule.makeConnection();
+ } else { //use Hikari Pool
+ ll_conn = null;
+ this.dataSource = this.benchmarkModule.getDataSource();
+ }
} catch (Exception ex) {
throw new RuntimeException("Failed to connect to database", ex);
}
@@ -215,6 +222,15 @@ synchronized public void cancelStatement() {
}
}
+ public void closeConnection() {
+ try {
+ if(ll_conn != null)
+ ll_conn.close();
+ } catch (SQLException e) {
+ LOG.error("Failed to close connection: " + e.getMessage());
+ }
+ }
+
public void test(Connection conn) throws Exception {
Procedure proc = this.getProcedure(
this.transactionTypes.getType("NewOrder").getProcedureClass());
@@ -480,19 +496,21 @@ protected final ArrayList> do
}
startConnection = System.nanoTime();
- conn = dataSource.getConnection();
+ if( !wrkld.getUseHikariPool()) {
+ conn = wrkld.getUseCreateConnForEveryTx() ? benchmarkModule.makeConnection() : ll_conn;
+ } else //use Hikari connection Pool
+ conn = dataSource.getConnection();
try {
- if(wrkld.getDBType().equals("yugabyte"))
+ if(wrkld.getDBType().equals("yugabyte")) {
+ conn.setAutoCommit(true);
conn.createStatement().execute("SET yb_enable_expression_pushdown to on");
- if (next.getProcedureClass() != StockLevel.class) {
- // In accordance with 2.8.2.3 of the TPCC spec, StockLevel should execute each query in its own Snapshot
- // Isolation.
- conn.setAutoCommit(false);
}
+ // In accordance with 2.8.2.3 of the TPCC spec, StockLevel should execute each query in its own Snapshot
+ // Isolation.
+ conn.setAutoCommit(next.getProcedureClass() == StockLevel.class);
} catch (Throwable e) {
-
+ LOG.info("Error in enabling expression_pushdown or setting auto_commit to false" + e.getMessage());
}
-
endConnection = System.nanoTime();
int attempt = 0;
@@ -592,7 +610,11 @@ protected final ArrayList> do
break;
}
} // WHILE
- conn.close();
+ if(!wrkld.getUseHikariPool()) {
+ if (wrkld.getUseCreateConnForEveryTx())
+ conn.close();
+ } else
+ conn.close();
} catch (SQLException ex) {
String msg = String.format("Unexpected fatal, error in '%s' when executing '%s'",
this, next);