mirror of
https://github.com/actiontech/dble.git
synced 2026-01-06 04:40:17 -06:00
add log
add log
This commit is contained in:
@@ -10,11 +10,14 @@ import com.actiontech.dble.config.ErrorCode;
|
||||
import com.actiontech.dble.services.mysqlauthenticate.MysqlDatabaseHandler;
|
||||
import com.actiontech.dble.util.StringUtil;
|
||||
import com.alibaba.druid.wall.WallProvider;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
public class RwSplitUserConfig extends ServerUserConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RwSplitUserConfig.class);
|
||||
private final String dbGroup;
|
||||
|
||||
public RwSplitUserConfig(UserConfig user, String tenant, WallProvider blacklist, String dbGroup) {
|
||||
@@ -45,6 +48,10 @@ public class RwSplitUserConfig extends ServerUserConfig {
|
||||
} else {
|
||||
exist = schemas.contains(schema);
|
||||
}
|
||||
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());
|
||||
}
|
||||
return exist ? 0 : ErrorCode.ER_BAD_DB_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ package com.actiontech.dble.services.mysqlauthenticate;
|
||||
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 org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -111,12 +112,16 @@ 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());
|
||||
if (result.isSuccess()) {
|
||||
List<Map<String, String>> rows = result.getResult();
|
||||
for (Map<String, String> row : rows) {
|
||||
String databaseName = row.get(mysqlShowDataBasesCol);
|
||||
databases.add(databaseName);
|
||||
}
|
||||
LOGGER.info("current databases size is {}, databases is {}", databases.size(), databases);
|
||||
} else {
|
||||
TraceUtil.print();
|
||||
}
|
||||
handleFinished();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
package com.actiontech.dble.sqlengine;
|
||||
|
||||
import com.actiontech.dble.util.TraceUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -33,6 +34,9 @@ public class MultiRowSQLQueryResultHandler extends OneRawSQLQueryResultHandler {
|
||||
|
||||
@Override
|
||||
public void finished(String shardingNode, boolean failed) {
|
||||
if (failed) {
|
||||
TraceUtil.print();
|
||||
}
|
||||
SQLQueryResult<List<Map<String, String>>> queryResult =
|
||||
new SQLQueryResult<>(this.resultRows, !failed, this.resultRows.isEmpty());
|
||||
if (callback != null)
|
||||
|
||||
@@ -96,6 +96,7 @@ public class SQLJob implements ResponseHandler, Runnable, Cloneable {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("con query sql:" + sql + " to con:" + conn);
|
||||
}
|
||||
LOGGER.info("con query sql:" + sql + " to con:" + conn);
|
||||
conn.getBackendService().setResponseHandler(this);
|
||||
conn.getBackendService().setComplexQuery(true);
|
||||
TraceManager.TraceObject traceObject = TraceManager.serviceTrace(conn.getBackendService(), "sql-job-send-command");
|
||||
@@ -103,7 +104,7 @@ public class SQLJob implements ResponseHandler, Runnable, Cloneable {
|
||||
conn.getBackendService().query(sql, true);
|
||||
connection = conn;
|
||||
} catch (Exception e) { // (UnsupportedEncodingException e) {
|
||||
LOGGER.debug("......", e);
|
||||
LOGGER.warn("connectionAcquired send error ", e);
|
||||
doFinished(true);
|
||||
} finally {
|
||||
TraceManager.finishSpan(traceObject);
|
||||
@@ -167,6 +168,7 @@ public class SQLJob implements ResponseHandler, Runnable, Cloneable {
|
||||
} else {
|
||||
((MySQLResponseService) service).release();
|
||||
}
|
||||
LOGGER.info("[okResponse] sql is{}, service is {}", sql, service);
|
||||
doFinished(false);
|
||||
}
|
||||
}
|
||||
@@ -187,11 +189,13 @@ public class SQLJob implements ResponseHandler, Runnable, Cloneable {
|
||||
@Override
|
||||
public void rowEofResponse(byte[] eof, boolean isLeft, AbstractService service) {
|
||||
((MySQLResponseService) service).release();
|
||||
LOGGER.info("[rowEofResponse] sql is{}, service is {}", sql, service);
|
||||
doFinished(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionClose(AbstractService service, String reason) {
|
||||
LOGGER.warn("connectionClose sql {}, reason is {}, service is {}", sql, reason, service);
|
||||
doFinished(true);
|
||||
}
|
||||
|
||||
|
||||
35
src/main/java/com/actiontech/dble/util/TraceUtil.java
Normal file
35
src/main/java/com/actiontech/dble/util/TraceUtil.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package com.actiontech.dble.util;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public final class TraceUtil {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TraceUtil.class);
|
||||
|
||||
private TraceUtil() {
|
||||
}
|
||||
|
||||
public static void print() {
|
||||
LOGGER.warn(printStackTrace());
|
||||
}
|
||||
|
||||
public static synchronized String printStackTrace() {
|
||||
Throwable throwable = new Throwable();
|
||||
StackTraceElement[] stackElements = throwable.getStackTrace();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String line = "\r\n";
|
||||
if (Objects.nonNull(stackElements)) {
|
||||
sb.append("start stack trace").append(line);
|
||||
for (int i = 0; i < stackElements.length; i++) {
|
||||
sb.append(stackElements[i].getClassName());
|
||||
sb.append(".").append(stackElements[i].getMethodName());
|
||||
sb.append("(").append(stackElements[i].getFileName()).append(":");
|
||||
sb.append(stackElements[i].getLineNumber() + ")").append(line);
|
||||
}
|
||||
sb.append("end stack trace").append(line);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user