Skip to content

Commit

Permalink
[improvement](jdbc) Set the JDBC connection timeout to be conf (apach…
Browse files Browse the repository at this point in the history
  • Loading branch information
zy-kkk authored Jun 20, 2023
1 parent c85271d commit 53b2fe5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bin/start_be.sh
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ java_version="$(
CUR_DATE=$(date +%Y%m%d-%H%M%S)
LOG_PATH="-DlogPath=${DORIS_HOME}/log/jni.log"
COMMON_OPTS="-Dsun.java.command=DorisBE -XX:-CriticalJNINatives"
JDBC_OPTS="-DJDBC_MIN_POOL=1 -DJDBC_MAX_POOL=100 -DJDBC_MAX_IDEL_TIME=300000"
JDBC_OPTS="-DJDBC_MIN_POOL=1 -DJDBC_MAX_POOL=100 -DJDBC_MAX_IDEL_TIME=300000 -DJDBC_MAX_WAIT_TIME=5000"

if [[ "${java_version}" -gt 8 ]]; then
if [[ -z ${JAVA_OPTS_FOR_JDK_9} ]]; then
Expand Down
4 changes: 2 additions & 2 deletions conf/be.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ CUR_DATE=`date +%Y%m%d-%H%M%S`

PPROF_TMPDIR="$DORIS_HOME/log/"

JAVA_OPTS="-Xmx1024m -DlogPath=$DORIS_HOME/log/jni.log -Xloggc:$DORIS_HOME/log/be.gc.log.$CUR_DATE -Dsun.java.command=DorisBE -XX:-CriticalJNINatives -DJDBC_MIN_POOL=1 -DJDBC_MAX_POOL=100 -DJDBC_MAX_IDEL_TIME=300000"
JAVA_OPTS="-Xmx1024m -DlogPath=$DORIS_HOME/log/jni.log -Xloggc:$DORIS_HOME/log/be.gc.log.$CUR_DATE -Dsun.java.command=DorisBE -XX:-CriticalJNINatives -DJDBC_MIN_POOL=1 -DJDBC_MAX_POOL=100 -DJDBC_MAX_IDEL_TIME=300000 -DJDBC_MAX_WAIT_TIME=5000"

# For jdk 9+, this JAVA_OPTS will be used as default JVM options
JAVA_OPTS_FOR_JDK_9="-Xmx1024m -DlogPath=$DORIS_HOME/log/jni.log -Xlog:gc:$DORIS_HOME/log/be.gc.log.$CUR_DATE -Dsun.java.command=DorisBE -XX:-CriticalJNINatives -DJDBC_MIN_POOL=1 -DJDBC_MAX_POOL=100 -DJDBC_MAX_IDEL_TIME=300000"
JAVA_OPTS_FOR_JDK_9="-Xmx1024m -DlogPath=$DORIS_HOME/log/jni.log -Xlog:gc:$DORIS_HOME/log/be.gc.log.$CUR_DATE -Dsun.java.command=DorisBE -XX:-CriticalJNINatives -DJDBC_MIN_POOL=1 -DJDBC_MAX_POOL=100 -DJDBC_MAX_IDEL_TIME=300000 -DJDBC_MAX_WAIT_TIME=5000"

# since 1.2, the JAVA_HOME need to be set to run BE process.
# JAVA_HOME=/path/to/jdk/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public class JdbcExecutor {
private int maxPoolSize;
private int minIdleSize;
private int maxIdelTime;
private int maxWaitTime;
private TOdbcTableType tableType;

public JdbcExecutor(byte[] thriftParams) throws Exception {
Expand All @@ -103,10 +104,12 @@ public JdbcExecutor(byte[] thriftParams) throws Exception {
minPoolSize = Integer.valueOf(System.getProperty("JDBC_MIN_POOL", "1"));
maxPoolSize = Integer.valueOf(System.getProperty("JDBC_MAX_POOL", "100"));
maxIdelTime = Integer.valueOf(System.getProperty("JDBC_MAX_IDEL_TIME", "300000"));
maxWaitTime = Integer.valueOf(System.getProperty("JDBC_MAX_WAIT_TIME", "5000"));
minIdleSize = minPoolSize > 0 ? 1 : 0;
LOG.info("JdbcExecutor set minPoolSize = " + minPoolSize
+ ", maxPoolSize = " + maxPoolSize
+ ", maxIdelTime = " + maxIdelTime
+ ", maxWaitTime = " + maxWaitTime
+ ", minIdleSize = " + minIdleSize);
init(request.driver_path, request.statement, request.batch_size, request.jdbc_driver_class,
request.jdbc_url, request.jdbc_user, request.jdbc_password, request.op, request.table_type);
Expand Down Expand Up @@ -416,7 +419,7 @@ private void init(String driverUrl, String sql, int batchSize, String driverClas
ds.setMinIdle(minIdleSize);
ds.setInitialSize(minPoolSize);
ds.setMaxActive(maxPoolSize);
ds.setMaxWait(5000);
ds.setMaxWait(maxWaitTime);
ds.setTestWhileIdle(true);
ds.setTestOnBorrow(false);
setValidationQuery(ds, tableType);
Expand Down

0 comments on commit 53b2fe5

Please sign in to comment.