question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Confused with method getMemUsage() in LinuxBrokerHostUsageImpl.java

See original GitHub issue

Environment

  1. broker run in kubernetes, set memory request to 20GB and limit to 20GB
  2. pulsar version 2.8.1
  3. os:ubuntu:20.04
  4. jdk: openjdk version “11.0.11” 2021-04-20
  5. PULSAR_GC: -XX:+UseG1GC -XX:MaxGCPauseMillis=10 -Dio.netty.leakDetectionLevel=disabled -Dio.netty.recycler.linkCapacity=1024 -XX:+ParallelRefProcEnabled -XX:+UnlockExperimentalVMOptions -XX:+DoEscapeAnalysis -XX:ParallelGCThreads=4 -XX:ConcGCThreads=4 -XX:G1NewSizePercent=50 -XX:+DisableExplicitGC -XX:-ResizePLAB -XX:+ExitOnOutOfMemoryError -XX:+PerfDisableSharedMem
  6. PULSAR_MEM: -Xms8G -Xmx8G -XX:MaxDirectMemorySize=8G

Describe the bug When running broker in our cluster, some broker pod may occur memory usage over 85%, and then cause to unloading namespace bundles from this broker, but from monitor of pod, we found the usage of memory is not high;on the other side, we found that when unloading bundles, jvm heap memory is very high, and the monitoring curve of jvm_memory_bytes_used is very similar to pulsar_lb_memory_usage

Question Does LinuxBrokerHostUsageImpl.getMemUsage() return error results? Why get different result in same pod?

To Reproduce

  1. test in the broker pod
import com.sun.management.OperatingSystemMXBean;
import java.lang.management.ManagementFactory;

public class MemTest {

    public static void main(String[] args) {
        OperatingSystemMXBean systemBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
        double total = ((double) systemBean.getTotalPhysicalMemorySize()) / (1024 * 1024);
        double free = ((double) systemBean.getFreePhysicalMemorySize()) / (1024 * 1024);

        System.out.println("total:" + total);
        System.out.println("free:" + free);
    }
}

and result of limit is 20GB.

image 2. use arthas to see the real return of LinuxBrokerHostUsageImpl.getMemUsage, and can see that the limit is 8GB. image

Expected behavior

LinuxBrokerHostUsageImpl.getMemUsage return the real memory of pod rather than the heap memory of jvm.

Screenshots 1.monitor of broker pod image 2.monitor of pulsar_lb_memory_usage image

Thanks for any suggestions.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
zhanghaoucommented, Aug 26, 2022

@tisonkun

It seems to a bug of arthas, not connected to jdk version. When I add more log in method getMemUsage(), total and used is correct. BTW, the memory of pod is useless, because of the override of jvm heap and direct memory in LoadManagerShared:getSystemResourceUsage() 企业微信截图_e7c24f36-7669-40bd-b663-58193ae45f14 企业微信截图_b6b3cbec-f278-4441-81e4-2ca535d3a92e 企业微信截图_af9fc3f7-3097-4476-9aa5-bcd8e7ce88c8

0reactions
tisonkuncommented, Aug 25, 2022

@zhanghaou So why do you close this issue as completed while JDK17 doesn’t help?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to properly use Exception method getMessage
If the message exists, then simply appened e.getMessage() to your string. You can also use e.printStackTrace() so you can see the full error....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found