Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Threads blocked trying to attach to the JVM #566

Merged
merged 6 commits into from
Mar 11, 2021
Merged

Threads blocked trying to attach to the JVM #566

merged 6 commits into from
Mar 11, 2021

Commits on Mar 1, 2021

  1. Threads blocked trying to attach to the JVM

    In [this code](https://github.com/opendistro-for-elasticsearch/performance-analyzer-rca/blob/b33c502d55b954782129b8f61b2c67b07e8477d5/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/jvm/ThreadList.java#L127) all threads might be blocked behind one thread trying to
    fill the jTidMap from a threaddump that contains all the thread related details that performanceAnalyzer uses. The thread dump is requires a JVM attach which has a [default timeout of 10 seconds](https://github.com/openjdk/jdk/blob/353416ffcaa12d79013e6f9d03371bf86d0f671b/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java#L368) which is quite long. While one thread is busy attaching, all threads running ES operations might be stuck waiting for the same lock. Therefore, this change replaces a mandatory lock with a try-lock, so that the threads which cannot acquire the lock, moves past this and carry on. We will loose the metrics for this run, but that is better than stalling all ES operations.
    
    Tests
    
    PA metrics is returning the metrics:
    ```
    curl "localhost:9600/_opendistro/_performanceanalyzer/metrics?metrics=Latency,CPU_Utilization&agg=avg,max&dim=ShardID&nodes=all"
    {"iAHcZIXUQMaOBPzRNsC-JA": {"timestamp": 1614637105000, "data": {"fields":[{"name":"ShardID","type":"VARCHAR"},{"name":"Latency","type":"DOUBLE"},{"name":"CPU_Utilization","type":"DOUBLE"}],"records":[[null,null,0.005394726328405913]]}}, "jLtljYrfQAuTVwUBgGtHNQ" :{"timestamp": 1614637105000, "data": {"fields":[{"name":"ShardID","type":"VARCHAR"},{"name":"Latency","type":"DOUBLE"},{"name":"CPU_Utilization","type":"DOUBLE"}],"records":[[null,null,0.002798561151079137]]}}}```
    
    The writer metrics are being emitted in the /dev/shm file
    ```
    [root@7b746ade07bd performanceanalyzer]# cat 1614636875000
    ^heap_metrics
    {"current_time":1614636875493}
    {"MemType":"totYoungGC","GC_Collection_Event":0,"GC_Collection_Time":0,"Heap_Committed":-2,"Heap_Init":-2,"Heap_Max":-2,"Heap_Used":-2}
    {"MemType":"totFullGC","GC_Collection_Event":0,"GC_Collection_Time":0,"Heap_Committed":-2,"Heap_Init":-2,"Heap_Max":-2,"Heap_Used":-2}
    {"MemType":"PermGen","GC_Collection_Event":-2,"GC_Collection_Time":-2,"Heap_Committed":85696512,"Heap_Init":0,"Heap_Max":-1,"Heap_Used":80593424}
    {"MemType":"Survivor","GC_Collection_Event":-2,"GC_Collection_Time":-2,"Heap_Committed":17891328,"Heap_Init":17891328,"Heap_Max":17891328,"Heap_Used":9578944}
    {"MemType":"OldGen","GC_Collection_Event":-2,"GC_Collection_Time":-2,"Heap_Committed":357957632,"Heap_Init":357957632,"Heap_Max":357957632,"Heap_Used":55396840}
    {"MemType":"Eden","GC_Collection_Event":-2,"GC_Collection_Time":-2,"Heap_Committed":143130624,"Heap_Init":143130624,"Heap_Max":143130624,"Heap_Used":37667024}
    {"MemType":"NonHeap","GC_Collection_Event":-2,"GC_Collection_Time":-2,"Heap_Committed":118042624,"Heap_Init":7667712,"Heap_Max":-1,"Heap_Used":109184376}
    {"MemType":"Heap","GC_Collection_Event":-2,"GC_Collection_Time":-2,"Heap_Committed":518979584,"Heap_Init":536870912,"Heap_Max":518979584,"Heap_Used":102642808}
    ```
    yojs committed Mar 1, 2021
    Configuration menu
    Copy the full SHA
    bdcd915 View commit details
    Browse the repository at this point in the history

Commits on Mar 2, 2021

  1. Configuration menu
    Copy the full SHA
    d5af22f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    569b7eb View commit details
    Browse the repository at this point in the history

Commits on Mar 5, 2021

  1. Configuration menu
    Copy the full SHA
    ff65aeb View commit details
    Browse the repository at this point in the history

Commits on Mar 6, 2021

  1. Configuration menu
    Copy the full SHA
    6fb5d69 View commit details
    Browse the repository at this point in the history

Commits on Mar 11, 2021

  1. Addressing review comments

    yojs committed Mar 11, 2021
    Configuration menu
    Copy the full SHA
    02fbb36 View commit details
    Browse the repository at this point in the history