mirror of
https://github.com/actiontech/dble.git
synced 2026-01-04 03:40:13 -06:00
inner-1859: release switch (#3355)
Signed-off-by: dcy <dcy10000@gmail.com>
Signed-off-by: dcy <dcy10000@gmail.com>
(cherry picked from commit bc7d40209d)
This commit is contained in:
@@ -214,6 +214,26 @@ public final class SystemConfig {
|
||||
private String gmsslOcaPem = null;
|
||||
private boolean supportSSL = false;
|
||||
|
||||
private int enableAsyncRelease = 0;
|
||||
//unit: ms
|
||||
private long releaseTimeout = 10 * 60 * 1000L;
|
||||
|
||||
public int getEnableAsyncRelease() {
|
||||
return enableAsyncRelease;
|
||||
}
|
||||
|
||||
public void setEnableAsyncRelease(int enableAsyncRelease) {
|
||||
this.enableAsyncRelease = enableAsyncRelease;
|
||||
}
|
||||
|
||||
public long getReleaseTimeout() {
|
||||
return releaseTimeout;
|
||||
}
|
||||
|
||||
public void setReleaseTimeout(long releaseTimeout) {
|
||||
this.releaseTimeout = releaseTimeout;
|
||||
}
|
||||
|
||||
public String getServerCertificateKeyStoreUrl() {
|
||||
return serverCertificateKeyStoreUrl;
|
||||
}
|
||||
@@ -1676,6 +1696,8 @@ public final class SystemConfig {
|
||||
", enableRoutePenetration=" + enableRoutePenetration +
|
||||
", routePenetrationRules='" + routePenetrationRules + '\'' +
|
||||
", groupConcatMaxLen='" + groupConcatMaxLen +
|
||||
", releaseTimeout=" + releaseTimeout +
|
||||
", enableAsyncRelease=" + enableAsyncRelease +
|
||||
"]";
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
package com.actiontech.dble.net.handler;
|
||||
|
||||
import com.actiontech.dble.config.model.SystemConfig;
|
||||
import com.actiontech.dble.net.connection.BackendConnection;
|
||||
import com.actiontech.dble.services.mysqlsharding.MySQLResponseService;
|
||||
|
||||
@@ -26,6 +27,32 @@ public class BackEndRecycleRunnable implements Runnable, BackEndCleaner {
|
||||
service.setRecycler(this);
|
||||
}
|
||||
|
||||
public void runSync() {
|
||||
BackendConnection conn = service.getConnection();
|
||||
if (conn.isClosed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
lock.lock();
|
||||
try {
|
||||
if (service.isRowDataFlowing()) {
|
||||
if (!condRelease.await(SystemConfig.getInstance().getReleaseTimeout(), TimeUnit.MILLISECONDS)) {
|
||||
if (!conn.isClosed()) {
|
||||
conn.businessClose("recycle time out");
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
service.getConnection().businessClose("recycle exception");
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
service.getConnection().businessClose("recycle exception");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -38,7 +65,7 @@ public class BackEndRecycleRunnable implements Runnable, BackEndCleaner {
|
||||
lock.lock();
|
||||
try {
|
||||
if (service.isRowDataFlowing()) {
|
||||
if (!condRelease.await(10, TimeUnit.MILLISECONDS)) {
|
||||
if (!condRelease.await(SystemConfig.getInstance().getReleaseTimeout(), TimeUnit.MILLISECONDS)) {
|
||||
if (!conn.isClosed()) {
|
||||
conn.businessClose("recycle time out");
|
||||
}
|
||||
|
||||
@@ -228,6 +228,9 @@ public class MySQLResponseService extends BackendService {
|
||||
protocolResponseHandler = defaultResponseHandler;
|
||||
}
|
||||
synAndDoExecuteMultiNode(synSQL, rrn, service.getCharset());
|
||||
} catch (Exception e) {
|
||||
LOGGER.info("route error {},{},{}", rrn, this, service);
|
||||
throw e;
|
||||
} finally {
|
||||
TraceManager.finishSpan(this, traceObject);
|
||||
}
|
||||
@@ -351,8 +354,13 @@ public class MySQLResponseService extends BackendService {
|
||||
if (logResponse.compareAndSet(false, true)) {
|
||||
session.setBackendResponseEndTime(this);
|
||||
}
|
||||
DbleServer.getInstance().getComplexQueryExecutor().execute(new BackEndRecycleRunnable(this));
|
||||
return false;
|
||||
if (SystemConfig.getInstance().getEnableAsyncRelease() == 1) {
|
||||
DbleServer.getInstance().getComplexQueryExecutor().execute(new BackEndRecycleRunnable(this));
|
||||
return false;
|
||||
} else {
|
||||
new BackEndRecycleRunnable(this).runSync();
|
||||
}
|
||||
|
||||
}
|
||||
complexQuery = false;
|
||||
attachment = null;
|
||||
|
||||
Reference in New Issue
Block a user