dill21yu opened a new issue, #17173: URL: https://github.com/apache/dolphinscheduler/issues/17173
### Search before asking - [x] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened 在 DolphinScheduler 的 DefaultMetricsProvider 中,获取 JVM 内存使用率时存在逻辑错误,导致 Master 服务误判为过载状态,进而阻止所有调度任务的提交。 **问题现象** 所有调度任务无法提交 Master 日志报 Overload 错误 实际系统指标和内存快照分析均正常 **问题原因** 当前代码直接从 jvm.memory.used 和 jvm.memory.max 获取单个测量值,而没有考虑这些指标有多个标签(tag)维度 导致可能错误地比较了不同内存区域的值(如用 Eden Space 的 used 值与 Code Cache 的 max 值比较,jvmMemoryUsedPercentage为1.9) 从提供的指标数据可以看到,JVM 内存指标有多个维度: area: heap/nonheap id: 具体内存区域名称  ### What you expected to happen master启动参数:-Xms4g -Xmx4g -Xmn2g **JVM相关指标:** HELP jvm_memory_used_bytes The amount of used memory # TYPE jvm_memory_used_bytes gauge jvm_memory_used_bytes{application="master-server",area="nonheap",id="Compressed Class Space",} 1.1395192E7 jvm_memory_used_bytes{application="master-server",area="nonheap",id="Code Cache",} 7.443136E7 jvm_memory_used_bytes{application="master-server",area="heap",id="PS Eden Space",} 1.758794104E9 jvm_memory_used_bytes{application="master-server",area="heap",id="PS Survivor Space",} 1951136.0 jvm_memory_used_bytes{application="master-server",area="nonheap",id="Metaspace",} 9.8894144E7 jvm_memory_used_bytes{application="master-server",area="heap",id="PS Old Gen",} 7.4584848E7 # HELP jvm_memory_max_bytes The maximum amount of memory in bytes that can be used for memory management # TYPE jvm_memory_max_bytes gauge jvm_memory_max_bytes{application="master-server",area="nonheap",id="Compressed Class Space",} 1.073741824E9 jvm_memory_max_bytes{application="master-server",area="nonheap",id="Code Cache",} 2.5165824E8 jvm_memory_max_bytes{application="master-server",area="heap",id="PS Eden Space",} 2.142240768E9 jvm_memory_max_bytes{application="master-server",area="heap",id="PS Survivor Space",} 2621440.0 jvm_memory_max_bytes{application="master-server",area="nonheap",id="Metaspace",} -1.0 jvm_memory_max_bytes{application="master-server",area="heap",id="PS Old Gen",} 2.147483648E9 **相关代码:** @Component public class DefaultMetricsProvider implements MetricsProvider { @Autowired private MeterRegistry meterRegistry; private SystemMetrics systemMetrics; private long lastRefreshTime = 0; private static final long SYSTEM_METRICS_REFRESH_INTERVAL = 1_000L; @Override public SystemMetrics getSystemMetrics() { if (System.currentTimeMillis() - lastRefreshTime < SYSTEM_METRICS_REFRESH_INTERVAL) { return systemMetrics; } double systemCpuUsage = meterRegistry.get("system.cpu.usage").gauge().value(); double processCpuUsage = meterRegistry.get("process.cpu.usage").gauge().value(); double jvmMemoryUsed = meterRegistry.get("jvm.memory.used").meter().measure().iterator().next().getValue(); double jvmMemoryMax = meterRegistry.get("jvm.memory.max").meter().measure().iterator().next().getValue(); long totalSystemMemory = OSUtils.getTotalSystemMemory(); long systemMemoryAvailable = OSUtils.getSystemAvailableMemoryUsed(); systemMetrics = SystemMetrics.builder() .systemCpuUsagePercentage(systemCpuUsage) .processCpuUsagePercentage(processCpuUsage) .totalCpuUsedPercentage(systemCpuUsage + processCpuUsage) .jvmMemoryUsed(jvmMemoryUsed) .jvmMemoryMax(jvmMemoryMax) .jvmMemoryUsedPercentage(jvmMemoryUsed / jvmMemoryMax) .systemMemoryUsed(totalSystemMemory - systemMemoryAvailable) .systemMemoryMax(totalSystemMemory) .systemMemoryUsedPercentage((double) (totalSystemMemory - systemMemoryAvailable) / totalSystemMemory) .diskUsedPercentage(OSUtils.getDiskUsedPercentage()) .build(); lastRefreshTime = System.currentTimeMillis(); return systemMetrics; } } ### How to reproduce 修改指标获取逻辑,应该: 原来的指标字段jvmMemoryUsed 、jvmMemoryMax 替换为 sum(alltags) 对 jvm.memory.used 和 jvm.memory.max 按相同标签维度进行求和 新增4个指标 jvmHeapUsed、jvmNoHeapUsed、jvmHeapMax、jvmNoHeapMax ### Anything else _No response_ ### Version 3.2.x ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
