private boolean checkServiceAndInstanceNumber() {
boolean result = serviceManager.getServiceCount() == MetricsMonitor.getDomCountMonitor().get();
result &= serviceManager.getInstanceCount() == MetricsMonitor.getIpCountMonitor().get();
Loggers.SRV_LOG.error("TAG: ServiceCount-{}-{}, InstanceCount-{}-{}", serviceManager.getServiceCount(),
MetricsMonitor.getDomCountMonitor().get(), serviceManager.getInstanceCount(),
MetricsMonitor.getIpCountMonitor().get());
return result;
基于改造后的JAR包运行后,发现日志如下:
2021-05-10 14:33:50,785 ERROR TAG: ServiceCount-0-0, InstanceCount-0-0
2021-05-10 14:33:55,775 ERROR TAG: ServiceCount-38-0, InstanceCount-251-251
2021-05-10 14:34:00,774 ERROR TAG: ServiceCount-38-38, InstanceCount-251-251
2021-05-10 14:34:05,774 ERROR TAG: ServiceCount-38-38, InstanceCount-251-251
2021-05-10 14:34:10,774 ERROR TAG: ServiceCount-38-38, InstanceCount-251-251
2021-05-10 14:34:15,774 ERROR TAG: ServiceCount-38-38, InstanceCount-251-251
2021-05-10 14:34:20,776 ERROR TAG: ServiceCount-38-38, InstanceCount-251-251
2021-05-10 14:34:25,774 ERROR TAG: ServiceCount-38-38, InstanceCount-251-219
2021-05-10 14:34:30,776 ERROR TAG: ServiceCount-38-38, InstanceCount-251-182
2021-05-10 14:34:35,774 ERROR TAG: ServiceCount-38-38, InstanceCount-251-182
2021-05-10 14:34:40,774 ERROR TAG: ServiceCount-38-38, InstanceCount-251-182
2021-05-10 14:34:45,774 ERROR TAG: ServiceCount-38-38, InstanceCount-251-182
2021-05-10 14:34:50,774 ERROR TAG: ServiceCount-38-38, InstanceCount-251-182
2021-05-10 14:34:55,774 ERROR TAG: ServiceCount-38-38, InstanceCount-251-214
2021-05-10 14:35:00,774 ERROR TAG: ServiceCount-38-38, InstanceCount-251-214
2021-05-10 14:35:05,774 ERROR TAG: ServiceCount-38-38, InstanceCount-251-214
也就是说通不过Check的原因是serviceManager.getInstanceCount() == MetricsMonitor.getIpCountMonitor().get()
持续返回false.
问题1:请问如何解决以上问题?
问题2:另外,还有1个困惑:假如当前升级成功+关闭双写后,下次重启一个节点是否仍然会做以上检查,如果彼时检查通不过,会不会产生数据一致性问题,而不能正常工作?