Skip to content

Commit

Permalink
[ISSUE alibaba#5109] Fix HealthCheckCommonV2 sometimes will not finis…
Browse files Browse the repository at this point in the history
…h the c… (alibaba#5110)

* [ISSUE alibaba#5109] Fix HealthCheckCommonV2 sometimes will not finish the checking flag.

* [ISSUE alibaba#5109] Add a warning log to a maybe-unreachable code at tcp check processor.
  • Loading branch information
pixystone authored Mar 16, 2021
1 parent bb9e374 commit ed1f244
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,27 @@ public void checkOk(HealthCheckTaskV2 task, Service service, String msg) {
try {
HealthCheckInstancePublishInfo instance = (HealthCheckInstancePublishInfo) task.getClient()
.getInstancePublishInfo(service);
if (null != instance && !instance.isHealthy()) {
String serviceName = service.getGroupedServiceName();
String clusterName = instance.getCluster();
if (instance.getOkCount().incrementAndGet() >= switchDomain.getCheckTimes()) {
if (switchDomain.isHealthCheckEnabled(serviceName) && !task.isCancelled() && distroMapper
.responsible(task.getClient().getResponsibleId())) {
healthStatusSynchronizer.instanceHealthStatusChange(true, task.getClient(), service, instance);
Loggers.EVT_LOG.info("serviceName: {} {POS} {IP-ENABLED} valid: {}:{}@{}, region: {}, msg: {}",
serviceName, instance.getIp(), instance.getPort(), clusterName,
UtilsAndCommons.LOCALHOST_SITE, msg);
if (instance == null) {
return;
}
try {
if (!instance.isHealthy()) {
String serviceName = service.getGroupedServiceName();
String clusterName = instance.getCluster();
if (instance.getOkCount().incrementAndGet() >= switchDomain.getCheckTimes()) {
if (switchDomain.isHealthCheckEnabled(serviceName) && !task.isCancelled() && distroMapper
.responsible(task.getClient().getResponsibleId())) {
healthStatusSynchronizer.instanceHealthStatusChange(true, task.getClient(), service, instance);
Loggers.EVT_LOG.info("serviceName: {} {POS} {IP-ENABLED} valid: {}:{}@{}, region: {}, msg: {}",
serviceName, instance.getIp(), instance.getPort(), clusterName,
UtilsAndCommons.LOCALHOST_SITE, msg);
}
} else {
Loggers.EVT_LOG.info("serviceName: {} {OTHER} {IP-ENABLED} pre-valid: {}:{}@{} in {}, msg: {}",
serviceName, instance.getIp(), instance.getPort(), clusterName, instance.getOkCount(), msg);
}
} else {
Loggers.EVT_LOG.info("serviceName: {} {OTHER} {IP-ENABLED} pre-valid: {}:{}@{} in {}, msg: {}",
serviceName, instance.getIp(), instance.getPort(), clusterName, instance.getOkCount(), msg);
}
} finally {
instance.resetFailCount();
instance.finishCheck();
}
Expand All @@ -124,23 +130,29 @@ public void checkFail(HealthCheckTaskV2 task, Service service, String msg) {
try {
HealthCheckInstancePublishInfo instance = (HealthCheckInstancePublishInfo) task.getClient()
.getInstancePublishInfo(service);
if (null != instance && instance.isHealthy()) {
String serviceName = service.getGroupedServiceName();
String clusterName = instance.getCluster();
if (instance.getFailCount().incrementAndGet() >= switchDomain.getCheckTimes()) {
if (switchDomain.isHealthCheckEnabled(serviceName) && !task.isCancelled() && distroMapper
.responsible(task.getClient().getResponsibleId())) {
healthStatusSynchronizer.instanceHealthStatusChange(false, task.getClient(), service, instance);
Loggers.EVT_LOG
.info("serviceName: {} {POS} {IP-DISABLED} invalid: {}:{}@{}, region: {}, msg: {}",
if (instance == null) {
return;
}
try {
if (instance.isHealthy()) {
String serviceName = service.getGroupedServiceName();
String clusterName = instance.getCluster();
if (instance.getFailCount().incrementAndGet() >= switchDomain.getCheckTimes()) {
if (switchDomain.isHealthCheckEnabled(serviceName) && !task.isCancelled() && distroMapper
.responsible(task.getClient().getResponsibleId())) {
healthStatusSynchronizer.instanceHealthStatusChange(false, task.getClient(), service, instance);
Loggers.EVT_LOG
.info("serviceName: {} {POS} {IP-DISABLED} invalid: {}:{}@{}, region: {}, msg: {}",
serviceName, instance.getIp(), instance.getPort(), clusterName,
UtilsAndCommons.LOCALHOST_SITE, msg);
}
} else {
Loggers.EVT_LOG.info("serviceName: {} {OTHER} {IP-DISABLED} pre-invalid: {}:{}@{} in {}, msg: {}",
serviceName, instance.getIp(), instance.getPort(), clusterName, instance.getFailCount(),
msg);
}
} else {
Loggers.EVT_LOG.info("serviceName: {} {OTHER} {IP-DISABLED} pre-invalid: {}:{}@{} in {}, msg: {}",
serviceName, instance.getIp(), instance.getPort(), clusterName, instance.getFailCount(),
msg);
}
} finally {
instance.resetOkCount();
instance.finishCheck();
}
Expand All @@ -160,16 +172,22 @@ public void checkFailNow(HealthCheckTaskV2 task, Service service, String msg) {
try {
HealthCheckInstancePublishInfo instance = (HealthCheckInstancePublishInfo) task.getClient()
.getInstancePublishInfo(service);
if (null != instance && instance.isHealthy()) {
String serviceName = service.getGroupedServiceName();
String clusterName = instance.getCluster();
if (switchDomain.isHealthCheckEnabled(serviceName) && !task.isCancelled() && distroMapper
.responsible(task.getClient().getResponsibleId())) {
healthStatusSynchronizer.instanceHealthStatusChange(false, task.getClient(), service, instance);
Loggers.EVT_LOG.info("serviceName: {} {POS} {IP-DISABLED} invalid: {}:{}@{}, region: {}, msg: {}",
serviceName, instance.getIp(), instance.getPort(), clusterName,
UtilsAndCommons.LOCALHOST_SITE, msg);
if (null == instance) {
return;
}
try {
if (instance.isHealthy()) {
String serviceName = service.getGroupedServiceName();
String clusterName = instance.getCluster();
if (switchDomain.isHealthCheckEnabled(serviceName) && !task.isCancelled() && distroMapper
.responsible(task.getClient().getResponsibleId())) {
healthStatusSynchronizer.instanceHealthStatusChange(false, task.getClient(), service, instance);
Loggers.EVT_LOG.info("serviceName: {} {POS} {IP-DISABLED} invalid: {}:{}@{}, region: {}, msg: {}",
serviceName, instance.getIp(), instance.getPort(), clusterName,
UtilsAndCommons.LOCALHOST_SITE, msg);
}
}
} finally {
instance.resetOkCount();
instance.finishCheck();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ public void run() {
key.channel().close();
} else {
// not terminate request, ignore
SRV_LOG.warn("Tcp check ok, but the connected server responses some msg. Connection won't be closed.");
}
}
} catch (ConnectException e) {
Expand Down

0 comments on commit ed1f244

Please sign in to comment.