Skip to content
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

[inner-2060] fix: database is not checked during login(cherry-pick) #3819

Merged
merged 1 commit into from
Sep 12, 2023
Merged
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
15 changes: 15 additions & 0 deletions src/main/java/com/actiontech/dble/config/model/SystemConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ private SystemConfig() {

private boolean closeHeartBeatRecord = false;

private int enableCheckSchema = 1;

private int enableAsyncRelease = 1;
//unit: ms
private long releaseTimeout = 10L;
Expand Down Expand Up @@ -1412,6 +1414,18 @@ public void setRoutePenetrationRules(String sqlPenetrationRegexesTmp) {
routePenetrationRules = sqlPenetrationRegexesTmp;
}

public int getEnableCheckSchema() {
return enableCheckSchema;
}

public void setEnableCheckSchema(int enableCheckSchema) {
if (enableCheckSchema >= 0 && enableCheckSchema <= 1) {
this.enableCheckSchema = enableCheckSchema;
} else if (this.problemReporter != null) {
problemReporter.warn(String.format(WARNING_FORMAT, "enableCheckSchema", enableCheckSchema, this.enableCheckSchema));
}
}

@Override
public String toString() {
return "SystemConfig [" +
Expand Down Expand Up @@ -1512,6 +1526,7 @@ public String toString() {
", routePenetrationRules='" + routePenetrationRules + '\'' +
", releaseTimeout=" + releaseTimeout +
", enableAsyncRelease=" + enableAsyncRelease +
", enableCheckSchema=" + enableCheckSchema +
"]";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import com.actiontech.dble.DbleServer;
import com.actiontech.dble.config.ErrorCode;
import com.actiontech.dble.config.model.SystemConfig;
import com.actiontech.dble.services.mysqlauthenticate.MysqlDatabaseHandler;
import com.actiontech.dble.util.StringUtil;
import com.alibaba.druid.wall.WallProvider;
Expand Down Expand Up @@ -37,6 +38,9 @@ public int checkSchema(String schema) {
if (schema == null) {
return 0;
}
if (SystemConfig.getInstance().getEnableCheckSchema() == 0) {
return 0;
}
boolean exist;
Set<String> schemas = new MysqlDatabaseHandler(DbleServer.getInstance().getConfig().getDbGroups()).execute(dbGroup);
if (DbleServer.getInstance().getSystemVariables().isLowerCaseTableNames()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ public void connectionError(Throwable e, Object attachment) {
@Override
public void errorResponse(byte[] data, AbstractService service) {
StatisticListener.getInstance().record(rwSplitService, r -> r.onBackendSqlError(data));
ErrorPacket errorPacket = new ErrorPacket();
errorPacket.read(data);
String error = "[MySQL Error Packet] " + new String(errorPacket.getMessage());
LOGGER.warn(error);
MySQLResponseService mysqlService = (MySQLResponseService) service;
loadDataClean();
initDbClean();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private SystemParams() {
readOnlyParams.add(new ParamInfo("routePenetrationRules", sysConfig.getRoutePenetrationRules() + "", "The config of route penetration"));
readOnlyParams.add(new ParamInfo("enableAsyncRelease", sysConfig.getEnableAsyncRelease() + "", "Whether enable async release . default value is 1(off)."));
readOnlyParams.add(new ParamInfo("releaseTimeout", sysConfig.getReleaseTimeout() + "", "time wait for release ,unit is ms, default value is 10 ms"));

readOnlyParams.add(new ParamInfo("enableCheckSchema", sysConfig.getEnableCheckSchema() + "", "Whether enable check schema, default value is 1(on)"));

}

Expand Down