Merge pull request #3849 from actiontech/log

optimize log display inner 2378
This commit is contained in:
wenyh
2023-12-19 10:03:42 +08:00
committed by GitHub
4 changed files with 17 additions and 17 deletions

View File

@@ -687,7 +687,7 @@ public class PhysicalDbGroup {
private void reportDisableError(PhysicalDbInstance ins) throws IOException {
final DbInstanceConfig config = ins.getConfig();
String disableError = "the dbInstance[" + config.getUrl() + "] is disable. Please check the dbInstance disable status";
String disableError = "the dbInstance[" + dbGroupConfig.getName() + ":" + config.getInstanceName() + ":" + config.getUrl() + "] is disable. Please check the dbInstance disable status";
LOGGER.warn(disableError);
Map<String, String> labels = AlertUtil.genSingleLabel("dbInstance", dbGroupConfig.getName() + "-" + config.getInstanceName());
AlertUtil.alert(AlarmCode.DB_INSTANCE_CAN_NOT_REACH, Alert.AlertLevel.WARN, disableError, "mysql", config.getId(), labels);
@@ -696,7 +696,7 @@ public class PhysicalDbGroup {
private void reportFakeNodeError(PhysicalDbInstance ins) throws IOException {
final DbInstanceConfig config = ins.getConfig();
String fakeNodeError = "the dbInstance[" + config.getUrl() + "] is fake node. Please check the dbInstance whether or not it is used";
String fakeNodeError = "the dbInstance[" + dbGroupConfig.getName() + ":" + config.getInstanceName() + ":" + config.getUrl() + "] is fake node. Please check the dbInstance whether or not it is used";
LOGGER.warn(fakeNodeError);
Map<String, String> labels = AlertUtil.genSingleLabel("dbInstance", dbGroupConfig.getName() + "-" + config.getInstanceName());
AlertUtil.alert(AlarmCode.DB_INSTANCE_CAN_NOT_REACH, Alert.AlertLevel.WARN, fakeNodeError, "mysql", config.getId(), labels);
@@ -705,7 +705,7 @@ public class PhysicalDbGroup {
private void reportHeartbeatError(PhysicalDbInstance ins) throws IOException {
final DbInstanceConfig config = ins.getConfig();
String heartbeatError = "the dbInstance[" + config.getUrl() + "] can't reach. Please check the dbInstance is accessible";
String heartbeatError = "the dbInstance[" + dbGroupConfig.getName() + ":" + config.getInstanceName() + ":" + config.getUrl() + "] can't reach. Please check the dbInstance is accessible";
if (dbGroupConfig.isShowSlaveSql()) {
heartbeatError += " and the privileges of user is sufficient (NOTE:heartbeat[show slave status] need grant the SUPER or REPLICATION CLIENT privilege(s) to db user,and then restart the dble or fresh conn).";
}

View File

@@ -229,14 +229,14 @@ public class DelayDetection {
}
private void setTimeout() {
LOGGER.warn("delayDetection to [" + source.getConfig().getUrl() + "] setTimeout");
LOGGER.warn("delayDetection to [" + source.getDbGroupConfig().getName() + ":" + source.getConfig().getUrl() + ":" + source.getConfig().getUrl() + "] setTimeout");
delayDetectionStatus = DelayDetectionStatus.TIMEOUT;
source.setDelayDetectionStatus(delayDetectionStatus);
alert(AlarmCode.DB_SLAVE_INSTANCE_DELAY, errorMessage, dbGroupConfig.instanceDatabaseType().name().toLowerCase());
}
private void setError() {
LOGGER.warn("delayDetection to [" + source.getConfig().getUrl() + "] setError");
LOGGER.warn("delayDetection to [" + source.getDbGroupConfig().getName() + ":" + source.getConfig().getUrl() + ":" + source.getConfig().getUrl() + "] setError");
delayDetectionStatus = DelayDetectionStatus.ERROR;
source.setDelayDetectionStatus(delayDetectionStatus);
if (!source.isReadInstance()) {
@@ -245,7 +245,7 @@ public class DelayDetection {
}
private void setOk() {
LOGGER.debug("delayDetection to [" + source.getConfig().getUrl() + "] setOK");
LOGGER.debug("delayDetection to [" + source.getDbGroupConfig().getName() + ":" + source.getConfig().getUrl() + ":" + source.getConfig().getUrl() + "] setOK");
if (errorCount.get() > 0) {
errorCount.set(0);
}

View File

@@ -111,7 +111,7 @@ public class MySQLDetector implements SQLQueryResultListener<SQLQueryResult<Map<
*/
private boolean checkRecoverFail(PhysicalDbInstance source) {
if (heartbeat.isStop()) {
LOGGER.warn("heartbeat[{}] had been stop", source.getConfig().getUrl());
LOGGER.warn("heartbeat[{}] had been stop", source.getDbGroupConfig().getName() + ":" + source.getConfig().getUrl() + ":" + source.getConfig().getUrl());
return true;
}
if (heartbeat.getStatus() == MySQLHeartbeatStatus.OK) { // ok->ok

View File

@@ -108,10 +108,10 @@ public class MySQLHeartbeat {
public void stop(String reason) {
if (isStop) {
LOGGER.warn("heartbeat[{}] had been stop", source.getConfig().getUrl());
LOGGER.warn("heartbeat[{}] had been stop", source.getDbGroupConfig().getName() + ":" + source.getConfig().getUrl() + ":" + source.getConfig().getUrl());
return;
}
LOGGER.info("stop heartbeat of instance[{}], due to {}", source.getConfig().getUrl(), reason);
LOGGER.info("stop heartbeat of instance[{}], due to {}", source.getDbGroupConfig().getName() + ":" + source.getConfig().getUrl() + ":" + source.getConfig().getUrl(), reason);
isStop = true;
scheduledFuture.cancel(false);
initHeartbeat.set(false);
@@ -164,7 +164,7 @@ public class MySQLHeartbeat {
}
void setErrorResult(String errMsg) {
LOGGER.warn("heartbeat to [" + source.getConfig().getUrl() + "] setError");
LOGGER.warn("heartbeat to [" + source.getDbGroupConfig().getName() + ":" + source.getConfig().getUrl() + ":" + source.getConfig().getUrl() + "] setError");
// should continue checking error status
if (detector != null) {
detector.quit();
@@ -203,7 +203,7 @@ public class MySQLHeartbeat {
private void setOk() {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("heartbeat to [" + source.getConfig().getUrl() + "] setOK");
LOGGER.debug("heartbeat to [" + source.getDbGroupConfig().getName() + ":" + source.getConfig().getUrl() + ":" + source.getConfig().getUrl() + "] setOK");
}
MySQLHeartbeatStatus previousStatus = status;
switch (status) {
@@ -212,17 +212,17 @@ public class MySQLHeartbeat {
this.errorCount.set(0);
this.startErrorTime.set(-1);
if (isStop) {
LOGGER.warn("heartbeat[{}] had been stop", source.getConfig().getUrl());
LOGGER.warn("heartbeat[{}] had been stop", source.getDbGroupConfig().getName() + ":" + source.getConfig().getUrl() + ":" + source.getConfig().getUrl());
detector.quit();
} else {
LOGGER.info("heartbeat to [{}] setOk, previous status is timeout", source.getConfig().getUrl());
LOGGER.info("heartbeat to [{}] setOk, previous status is timeout", source.getDbGroupConfig().getName() + ":" + source.getConfig().getUrl() + ":" + source.getConfig().getUrl());
heartbeat(); // timeout, heart beat again
}
break;
case OK:
break;
default:
LOGGER.info("heartbeat to [{}] setOk, previous status is {}", source.getConfig().getUrl(), status);
LOGGER.info("heartbeat to [{}] setOk, previous status is {}", source.getDbGroupConfig().getName() + ":" + source.getConfig().getUrl() + ":" + source.getConfig().getUrl(), status);
this.status = MySQLHeartbeatStatus.OK;
this.errorCount.set(0);
this.startErrorTime.set(-1);
@@ -236,7 +236,7 @@ public class MySQLHeartbeat {
source.updatePoolCapacity();
}
if (isStop) {
LOGGER.warn("heartbeat[{}] had been stop", source.getConfig().getUrl());
LOGGER.warn("heartbeat[{}] had been stop", source.getDbGroupConfig().getName() + ":" + source.getConfig().getUrl() + ":" + source.getConfig().getUrl());
detector.quit();
}
}
@@ -253,10 +253,10 @@ public class MySQLHeartbeat {
private void setTimeout() {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("heartbeat to [" + source.getConfig().getUrl() + "] setTimeout");
LOGGER.debug("heartbeat to [" + source.getDbGroupConfig().getName() + ":" + source.getConfig().getUrl() + ":" + source.getConfig().getUrl() + "] setTimeout");
}
if (status != MySQLHeartbeatStatus.TIMEOUT) {
LOGGER.warn("heartbeat to [{}] setTimeout, previous status is {}", source.getConfig().getUrl(), status);
LOGGER.warn("heartbeat to [{}] setTimeout, previous status is {}", source.getDbGroupConfig().getName() + ":" + source.getConfig().getUrl() + ":" + source.getConfig().getUrl(), status);
status = MySQLHeartbeatStatus.TIMEOUT;
}
}