8292541: [Metrics] Reported memory limit may exceed physical machine memory

Reviewed-by: stuefe, sgehwolf
This commit is contained in:
Jonathan Dowland 2022-08-26 16:22:14 +00:00 committed by Severin Gehwolf
parent c74b6d4552
commit 9a0d1e7ce8
3 changed files with 52 additions and 16 deletions

View file

@ -121,7 +121,13 @@ public class CgroupMetrics implements Metrics {
@Override
public long getMemoryLimit() {
return subsystem.getMemoryLimit();
long subsMem = subsystem.getMemoryLimit();
// Catch the cgroup memory limit exceeding host physical memory.
// Treat this as unlimited.
if (subsMem >= getTotalMemorySize0()) {
return CgroupSubsystem.LONG_RETVAL_UNLIMITED;
}
return subsMem;
}
@Override
@ -178,5 +184,6 @@ public class CgroupMetrics implements Metrics {
}
private static native boolean isUseContainerSupport();
private static native long getTotalMemorySize0();
}