Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions config/workload_all_conn_mngr.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0"?>
<parameters>
<dbtype>yugabyte</dbtype>
<driver>com.yugabyte.Driver</driver>
<port>5433</port>
<username>yugabyte</username>
<DBName>yugabyte</DBName>
<password></password>
<isolation>TRANSACTION_REPEATABLE_READ</isolation>

<sslCert></sslCert>
<sslKey></sslKey>
<jdbcURL></jdbcURL>

<useHikariPool>false</useHikariPool>
<createConnForEveryTx>false</createConnForEveryTx>

<batchSize>128</batchSize>
<useKeyingTime>true</useKeyingTime>
<useThinkTime>true</useThinkTime>
<enableForeignKeysAfterLoad>true</enableForeignKeysAfterLoad>
<hikariConnectionTimeoutMs>180000</hikariConnectionTimeoutMs>
<useStoredProcedures>true</useStoredProcedures>
<displayEnhancedLatencyMetrics>false</displayEnhancedLatencyMetrics>
<trackPerSQLStmtLatencies>false</trackPerSQLStmtLatencies>

<transactiontypes>
<transaction>
<name>NewOrder</name>
<weight>45</weight>
</transaction>
<transaction>
<name>Payment</name>
<weight>43</weight>
</transaction>
<transaction>
<name>OrderStatus</name>
<weight>4</weight>
</transaction>
<transaction>
<name>Delivery</name>
<weight>4</weight>
</transaction>
<transaction>
<name>StockLevel</name>
<weight>4</weight>
</transaction>
</transactiontypes>

<runtime>1800</runtime>
<rate>10000</rate>
<!--
Set the number of retries to 0 as retrying when the number of warehouses is
high is pointless as it just leads to more failures.
-->
<maxRetriesPerTransaction>2</maxRetriesPerTransaction>
<maxLoaderRetries>2</maxLoaderRetries>

</parameters>
59 changes: 59 additions & 0 deletions config/workload_all_conn_newConn_everyTxn.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0"?>
<parameters>
<dbtype>yugabyte</dbtype>
<driver>com.yugabyte.Driver</driver>
<port>5433</port>
<username>yugabyte</username>
<DBName>yugabyte</DBName>
<password></password>
<isolation>TRANSACTION_REPEATABLE_READ</isolation>

<sslCert></sslCert>
<sslKey></sslKey>
<jdbcURL></jdbcURL>

<useHikariPool>false</useHikariPool>
<createConnForEveryTx>true</createConnForEveryTx>

<batchSize>128</batchSize>
<useKeyingTime>true</useKeyingTime>
<useThinkTime>true</useThinkTime>
<enableForeignKeysAfterLoad>true</enableForeignKeysAfterLoad>
<hikariConnectionTimeoutMs>180000</hikariConnectionTimeoutMs>
<useStoredProcedures>true</useStoredProcedures>
<displayEnhancedLatencyMetrics>false</displayEnhancedLatencyMetrics>
<trackPerSQLStmtLatencies>false</trackPerSQLStmtLatencies>

<transactiontypes>
<transaction>
<name>NewOrder</name>
<weight>45</weight>
</transaction>
<transaction>
<name>Payment</name>
<weight>43</weight>
</transaction>
<transaction>
<name>OrderStatus</name>
<weight>4</weight>
</transaction>
<transaction>
<name>Delivery</name>
<weight>4</weight>
</transaction>
<transaction>
<name>StockLevel</name>
<weight>4</weight>
</transaction>
</transactiontypes>

<runtime>1800</runtime>
<rate>10000</rate>
<!--
Set the number of retries to 0 as retrying when the number of warehouses is
high is pointless as it just leads to more failures.
-->
<maxRetriesPerTransaction>2</maxRetriesPerTransaction>
<maxLoaderRetries>2</maxLoaderRetries>

</parameters>
8 changes: 8 additions & 0 deletions src/com/oltpbenchmark/ConfigFileOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ public Optional<Boolean> getUseThinkTime() {
return getBoolOpt("useThinkTime");
}

public Optional<Boolean> getUseHikariPool() {
return getBoolOpt("useHikariPool");
}

public Optional<Boolean> getCreateConnForEveryTx() {
return getBoolOpt("createConnForEveryTx");
}

public Optional<Boolean> getEnableForeignKeysAfterLoad() {
return getBoolOpt("enableForeignKeysAfterLoad");
}
Expand Down
2 changes: 2 additions & 0 deletions src/com/oltpbenchmark/DBWorkload.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/com/oltpbenchmark/ThreadBench.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ private int finalizeWorkers(ArrayList<Thread> workerThreads) throws InterruptedE
*/

requests += w.getRequests();
w.closeConnection();
}
testState = null;
return requests;
Expand Down
12 changes: 12 additions & 0 deletions src/com/oltpbenchmark/WorkloadConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 4 additions & 1 deletion src/com/oltpbenchmark/api/BenchmarkModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
42 changes: 32 additions & 10 deletions src/com/oltpbenchmark/api/Worker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -480,19 +496,21 @@ protected final ArrayList<Pair<TransactionExecutionState, TransactionStatus>> 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;

Expand Down Expand Up @@ -592,7 +610,11 @@ protected final ArrayList<Pair<TransactionExecutionState, TransactionStatus>> 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);
Expand Down