-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable Hikari Connection Pool for using only YSQL Connection Manager #157
base: master
Are you sure you want to change the base?
Changes from 5 commits
17646f8
d79fe27
4c05101
7635af8
95f00d2
a59450a
620c938
f23bda1
f53a8bd
3a01a88
22dc8dd
69adb7a
eab9b08
88ce709
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
<sslCert></sslCert> | ||
<sslKey></sslKey> | ||
<jdbcURL></jdbcURL> | ||
<useConnMngr>false</useConnMngr> | ||
<useShortLivedConn>false</useShortLivedConn> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. useShortLivedConn --> createConnForEveryTx |
||
|
||
<batchSize>128</batchSize> | ||
<useKeyingTime>true</useKeyingTime> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?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> | ||
<useConnMngr>true</useConnMngr> | ||
<useShortLivedConn>false</useShortLivedConn> | ||
|
||
<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> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?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> | ||
<useConnMngr>true</useConnMngr> | ||
<useShortLivedConn>true</useShortLivedConn> | ||
|
||
<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> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
package com.oltpbenchmark.api; | ||
|
||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.Statement; | ||
import java.sql.SQLException; | ||
import java.util.*; | ||
|
@@ -51,12 +52,11 @@ public class Worker implements Runnable { | |
private TransactionLatencyRecord latencies; | ||
private TransactionLatencyRecord failureLatencies; | ||
private WorkerTaskLatencyRecord workerTaskLatencyRecord; | ||
|
||
private final Statement currStatement; | ||
|
||
// Interval requests used by the monitor | ||
private final AtomicInteger intervalRequests = new AtomicInteger(0); | ||
|
||
private Connection ll_conn; | ||
private final int id; | ||
private final BenchmarkModule benchmarkModule; | ||
protected final HikariDataSource dataSource; | ||
|
@@ -81,7 +81,15 @@ public Worker( | |
|
||
assert (this.transactionTypes != null) : "The TransactionTypes from the WorkloadConfiguration is null!"; | ||
try { | ||
this.dataSource = this.benchmarkModule.getDataSource(); | ||
if(wrkld.getUseConnMngr()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. very confusing and hard to read code if (connManager && shortLivedConnections) } |
||
this.dataSource = null; | ||
if(!wrkld.getUseShortLivedConn()) { | ||
ll_conn = benchmarkModule.makeConnection(); | ||
System.out.println("Using connection manager for long lived connection without HikariPool"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dont use System.out.println There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is just for debugging purpose |
||
} | ||
} else { | ||
this.dataSource = this.benchmarkModule.getDataSource(); | ||
} | ||
} catch (Exception ex) { | ||
throw new RuntimeException("Failed to connect to database", ex); | ||
} | ||
|
@@ -473,14 +481,18 @@ protected final ArrayList<Pair<TransactionExecutionState, TransactionStatus>> do | |
|
||
TransactionStatus status = TransactionStatus.RETRY; | ||
|
||
Connection conn; | ||
Connection conn = ll_conn; | ||
try { | ||
if (next == null) { | ||
next = transactionTypes.getType(pieceOfWork.getType()); | ||
} | ||
startConnection = System.nanoTime(); | ||
|
||
conn = dataSource.getConnection(); | ||
if(wrkld.getUseConnMngr()){ | ||
if(wrkld.getUseShortLivedConn()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if (connManager && shortLivedConnections)
} |
||
conn = benchmarkModule.makeConnection(); | ||
} else { | ||
conn = dataSource.getConnection(); | ||
} | ||
try { | ||
if(wrkld.getDBType().equals("yugabyte")) | ||
conn.createStatement().execute("SET yb_enable_expression_pushdown to on"); | ||
|
@@ -490,7 +502,7 @@ protected final ArrayList<Pair<TransactionExecutionState, TransactionStatus>> do | |
conn.setAutoCommit(false); | ||
} | ||
} catch (Throwable e) { | ||
|
||
System.out.println("Error in enabling expression_pushdown or setting auto_commit to false "); | ||
} | ||
|
||
endConnection = System.nanoTime(); | ||
|
@@ -592,7 +604,11 @@ protected final ArrayList<Pair<TransactionExecutionState, TransactionStatus>> do | |
break; | ||
} | ||
} // WHILE | ||
conn.close(); | ||
if(wrkld.getUseConnMngr()) { | ||
if (wrkld.getUseShortLivedConn()) | ||
conn.close(); | ||
} else | ||
conn.close(); | ||
sonalsagarwal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} catch (SQLException ex) { | ||
String msg = String.format("Unexpected fatal, error in '%s' when executing '%s'", | ||
this, next); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useConnMngr --> useHikariPool