fix

fix
This commit is contained in:
lin
2022-12-19 14:36:13 +08:00
parent f4a9b7cca8
commit 490fa556f6
6 changed files with 34 additions and 9 deletions

View File

@@ -41,7 +41,9 @@ public class RwSplitUserConfig extends ServerUserConfig {
return 0;
}
boolean exist;
LOGGER.info("start checkSchema");
Set<String> schemas = new MysqlDatabaseHandler(DbleServer.getInstance().getConfig().getDbGroups()).execute(dbGroup);
LOGGER.info("checkSchema schemas size is {}, schemas content is {}, current schema is {} ", schemas.size(), schemas, schema);
if (DbleServer.getInstance().getSystemVariables().isLowerCaseTableNames()) {
Optional<String> result = schemas.stream().filter(item -> StringUtil.equals(item.toLowerCase(), schema.toLowerCase())).findFirst();
exist = result.isPresent();
@@ -50,8 +52,9 @@ public class RwSplitUserConfig extends ServerUserConfig {
}
if (!exist) {
LOGGER.warn("current schemas size is {}, schemas content is {}, current schema is {} ", schemas.size(), schemas, schema);
LOGGER.warn("dble lowerCase is {} ", DbleServer.getInstance().getSystemVariables().isLowerCaseTableNames());
LOGGER.warn("dble lowerCase is {}", DbleServer.getInstance().getSystemVariables().isLowerCaseTableNames());
}
LOGGER.info("end checkSchema");
return exist ? 0 : ErrorCode.ER_BAD_DB_ERROR;
}

View File

@@ -159,4 +159,15 @@ public class ChangeUserPacket extends MySQLPacket {
return tenant;
}
@Override
public String toString() {
return "ChangeUserPacket{" +
"clientFlags=" + clientFlags +
", charsetIndex=" + charsetIndex +
", user='" + user + '\'' +
", database='" + database + '\'' +
", authPlugin='" + authPlugin + '\'' +
", tenant='" + tenant + '\'' +
'}';
}
}

View File

@@ -9,6 +9,7 @@ import com.actiontech.dble.backend.datasource.PhysicalDbGroup;
import com.actiontech.dble.backend.datasource.PhysicalDbInstance;
import com.actiontech.dble.sqlengine.*;
import com.actiontech.dble.util.TraceUtil;
import com.google.common.collect.Sets;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -22,7 +23,7 @@ public class MysqlDatabaseHandler {
private static final String MYSQL_SHOW_DATABASES = "show databases";
private final ReentrantLock lock = new ReentrantLock();
private Map<String, PhysicalDbGroup> dbGroups;
private Set<String> databases = new HashSet<>();
private Set<String> databases = Sets.newConcurrentHashSet();
private final Condition finishCond = lock.newCondition();
private boolean isFinish = false;
@@ -72,6 +73,7 @@ public class MysqlDatabaseHandler {
if (dbGroup != null) {
ds = dbGroup.rwSelect(null, false);
}
LOGGER.info("current ds is {}", ds);
} catch (IOException e) {
LOGGER.warn("select dbInstance error", e);
}
@@ -112,7 +114,7 @@ public class MysqlDatabaseHandler {
@Override
public void onResult(SQLQueryResult<List<Map<String, String>>> result) {
LOGGER.info("current result size is {}, result is {}", result.getResult().size(), result.getResult());
LOGGER.info("current result size is {}, result is {}, isSuc {}", result.getResult().size(), result.getResult(), result.isSuccess());
if (result.isSuccess()) {
List<Map<String, String>> rows = result.getResult();
for (Map<String, String> row : rows) {

View File

@@ -18,12 +18,16 @@ import com.actiontech.dble.services.mysqlauthenticate.PluginName;
import com.actiontech.dble.services.mysqlauthenticate.SecurityUtil;
import com.actiontech.dble.singleton.FrontendUserManager;
import com.actiontech.dble.util.IPAddressUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.UnknownHostException;
import java.security.NoSuchAlgorithmException;
import java.util.Set;
public final class AuthUtil {
protected static final Logger LOGGER = LoggerFactory.getLogger(AuthUtil.class);
private AuthUtil() {
}
@@ -52,6 +56,7 @@ public final class AuthUtil {
}
// check schema
final String schema = authPacket.getDatabase();
LOGGER.info("frontConn is {}, schema is {}", fconn, schema);
switch (userConfig.checkSchema(schema)) {
case ErrorCode.ER_BAD_DB_ERROR:
return new AuthResultInfo("Unknown database '" + schema + "'");
@@ -94,6 +99,7 @@ public final class AuthUtil {
}
// check schema
final String schema = changeUserPacket.getDatabase();
LOGGER.info("frontConn is {}, schema is {} user is {}", fconn, schema, changeUserPacket);
switch (userConfig.checkSchema(schema)) {
case ErrorCode.ER_BAD_DB_ERROR:
return new AuthResultInfo("Unknown database '" + schema + "'");

View File

@@ -28,10 +28,7 @@ import org.slf4j.LoggerFactory;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.LockSupport;
@@ -203,6 +200,7 @@ public class MySQLResponseService extends BackendService {
if (protocolResponseHandler != defaultResponseHandler) {
protocolResponseHandler = defaultResponseHandler;
}
LOGGER.info("sqySQL is {}, query is {}, conn is {}", Optional.ofNullable(synSQL).orElse(new StringBuilder("null")), query, connection);
synAndDoExecute(synSQL, rrn.getStatement(), connection.getCharsetName());
}

View File

@@ -19,6 +19,7 @@ import com.actiontech.dble.route.RouteResultsetNode;
import com.actiontech.dble.server.parser.ServerParse;
import com.actiontech.dble.services.mysqlsharding.MySQLResponseService;
import com.actiontech.dble.singleton.TraceManager;
import com.actiontech.dble.util.TraceUtil;
import com.google.common.collect.ImmutableMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -121,6 +122,8 @@ public class SQLJob implements ResponseHandler, Runnable, Cloneable {
jobHandler.finished(shardingNode == null ? schema : shardingNode, failed);
return true;
}
LOGGER.warn("[doFinished] sql is {}, conn is {}", sql, connection);
TraceUtil.print();
return false;
}
@@ -162,20 +165,22 @@ public class SQLJob implements ResponseHandler, Runnable, Cloneable {
@Override
public void okResponse(byte[] ok, AbstractService service) {
LOGGER.info("[okResponse] sql is {}, sync is {}, service is {} conn is {}", sql, ((MySQLResponseService) service).syncAndExecute(), service, connection);
if (((MySQLResponseService) service).syncAndExecute()) {
if (testXid) {
service.getConnection().businessClose("test xid existence");
} else {
((MySQLResponseService) service).release();
}
LOGGER.info("[okResponse] sql is{}, service is {}", sql, service);
doFinished(false);
}
}
@Override
public void fieldEofResponse(byte[] header, List<byte[]> fields, List<FieldPacket> fieldPackets, byte[] eof,
boolean isLeft, AbstractService service) {
LOGGER.info("[fieldEofResponse] sql is {}, service is {}, conn is {}", sql, service, connection);
jobHandler.onHeader(fields);
}
@@ -188,8 +193,8 @@ public class SQLJob implements ResponseHandler, Runnable, Cloneable {
@Override
public void rowEofResponse(byte[] eof, boolean isLeft, AbstractService service) {
LOGGER.info("[rowEofResponse] sql is {}, service is {}, conn is {}", sql, service, connection);
((MySQLResponseService) service).release();
LOGGER.info("[rowEofResponse] sql is{}, service is {}", sql, service);
doFinished(false);
}