# Opensearch-performance-analyzer.service - java.lang.IllegalArgumentException: cannot add context to list

**URL:** <https://forum.opensearch.org/t/opensearch-performance-analyzer-service-java-lang-illegalargumentexception-cannot-add-context-to-list/18365>\
**Category:** Performance Analyzer\
**Created:** [March 13, 2024, 9:14pm UTC](https://forum.opensearch.org/t/opensearch-performance-analyzer-service-java-lang-illegalargumentexception-cannot-add-context-to-list/18365 "2024-03-13T21:14:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![user481937](https://avatars.discourse-cdn.com/v4/letter/u/ce7236/32.png) [@user481937](https://forum.opensearch.org/u/user481937)\
**Post date:** [March 13, 2024, 9:14pm UTC](https://forum.opensearch.org/t/opensearch-performance-analyzer-service-java-lang-illegalargumentexception-cannot-add-context-to-list/18365/1 "2024-03-13T21:14:16Z")

</div>

**Versions** (relevant - OpenSearch/Dashboard/Server OS/Browser):  
OpenSearch: 2.12.0  
OS: Ubuntu 20.0.4.6 LTS

**Describe the issue** :

A fresh installation of OpenSearch 2.12.0 for testing purposes developed interest in the Performance Analyzer feature that led to the discovery of this exception:

```auto
user@ip-10-1-1-2:~$ sudo systemctl status --full --no-pager opensearch-performance-analyzer
● opensearch-performance-analyzer.service - OpenSearch Performance Analyzer
     Loaded: loaded (/lib/systemd/system/opensearch-performance-analyzer.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2024-03-13 20:54:46 UTC; 9min ago
   Main PID: 1735 (java)
      Tasks: 17 (limit: 9252)
     Memory: 80.3M
     CGroup: /system.slice/opensearch-performance-analyzer.service
             └─1735 /usr/share/opensearch/jdk/bin/java -Xshare:auto -Xms4m -Xmx64m -XX:+UseSerialGC -Dlog4j.configurationFile=/etc/opensearch/opensearch-performance-analyzer/log4j2.xml -Xms64M -Xmx64M -XX:+UseSerialGC -XX:CICompilerCount=1 -XX:-TieredCompilation -XX:InitialCodeCacheSize=4096 -XX:MaxRAM=400m -Dopensearch.path.home=/usr/share/opensearch -Dopensearch.path.conf=/etc/opensearch -Dopensearch.distribution.type=deb -cp /usr/share/opensearch/lib/*:/usr/share/opensearch/performance-analyzer-rca/lib/* org.opensearch.performanceanalyzer.PerformanceAnalyzerApp

Mar 13 20:54:46 ip-10-1-1-2 systemd[1]: Started OpenSearch Performance Analyzer.
Mar 13 20:54:48 ip-10-1-1-2 performance-analyzer-agent-cli[1735]: Exception in thread "main" java.lang.IllegalArgumentException: cannot add context to list
Mar 13 20:54:48 ip-10-1-1-2 performance-analyzer-agent-cli[1735]: at jdk.httpserver/sun.net.httpserver.ContextList.add(ContextList.java:37)
Mar 13 20:54:48 ip-10-1-1-2 performance-analyzer-agent-cli[1735]: at jdk.httpserver/sun.net.httpserver.ServerImpl.createContext(ServerImpl.java:276)
Mar 13 20:54:48 ip-10-1-1-2 performance-analyzer-agent-cli[1735]: at jdk.httpserver/sun.net.httpserver.HttpServerImpl.createContext(HttpServerImpl.java:74)
Mar 13 20:54:48 ip-10-1-1-2 performance-analyzer-agent-cli[1735]: at jdk.httpserver/sun.net.httpserver.HttpServerImpl.createContext(HttpServerImpl.java:39)
Mar 13 20:54:48 ip-10-1-1-2 performance-analyzer-agent-cli[1735]: at org.opensearch.performanceanalyzer.PerformanceAnalyzerApp.createClientServers(PerformanceAnalyzerApp.java:354)
Mar 13 20:54:48 ip-10-1-1-2 performance-analyzer-agent-cli[1735]: at org.opensearch.performanceanalyzer.PerformanceAnalyzerApp.createClientServers(PerformanceAnalyzerApp.java:319)
Mar 13 20:54:48 ip-10-1-1-2 performance-analyzer-agent-cli[1735]: at org.opensearch.performanceanalyzer.PerformanceAnalyzerApp.main(PerformanceAnalyzerApp.java:112)
user@ip-10-1-1-2:~$

```

**Configuration** :

- 3 Nodes
- `node.roles: [cluster_manager,data,ingest]`

**Relevant Logs or Screenshots** :

```auto
-rw-r--r-- 1 opensearch opensearch 0 Mar 12 13:20 PerformanceAnalyzer.log

$ tail performance_analyzer_agent_stats.log
------------------------------------------------------------------------
Program=PerformanceAnalyzerAgent
rca-version=0.0.1
Metrics=
StartTime=0.000
EndTime=Wed, 13 Mar 2024 21:11:43 UTC
Time=1710364303325 msecs
Timing=total-time:1.710364303325E12/1
Counters=
EOE
$

```

---

<div class="post-metadata">

**Author:** ![user481937](https://avatars.discourse-cdn.com/v4/letter/u/ce7236/32.png) [@user481937](https://forum.opensearch.org/u/user481937)\
**Post date:** [March 18, 2024, 10:02pm UTC](https://forum.opensearch.org/t/opensearch-performance-analyzer-service-java-lang-illegalargumentexception-cannot-add-context-to-list/18365/2 "2024-03-18T22:02:06Z")

</div>

This issue is now documented in a bug report:

> <https://github.com/opensearch-project/performance-analyzer/issues/637>
>
> \*\*What is the bug?\*\*
> The \`performance-analyzer-agent-cli\` generates the followi…ng exception during startup in OpenSearch 2.12.0:
> 
> \`\`\`
> user@ip-10-1-1-2:~$ sudo systemctl status --full --no-pager opensearch-performance-analyzer
> ● opensearch-performance-analyzer.service - OpenSearch Performance Analyzer
> Loaded: loaded (/lib/systemd/system/opensearch-performance-analyzer.service; enabled; vendor preset: enabled)
> Active: active (running) since Wed 2024-03-13 20:54:46 UTC; 9min ago
> Main PID: 1735 (java)
> Tasks: 17 (limit: 9252)
> Memory: 80.3M
> CGroup: /system.slice/opensearch-performance-analyzer.service
> └─1735 /usr/share/opensearch/jdk/bin/java -Xshare:auto -Xms4m -Xmx64m -XX:+UseSerialGC -Dlog4j.configurationFile=/etc/opensearch/opensearch-performance-analyzer/log4j2.xml -Xms64M -Xmx64M -XX:+UseSerialGC -XX:CICompilerCount=1 -XX:-TieredCompilation -XX:InitialCodeCacheSize=4096 -XX:MaxRAM=400m -Dopensearch.path.home=/usr/share/opensearch -Dopensearch.path.conf=/etc/opensearch -Dopensearch.distribution.type=deb -cp /usr/share/opensearch/lib/\*:/usr/share/opensearch/performance-analyzer-rca/lib/\* org.opensearch.performanceanalyzer.PerformanceAnalyzerApp
> 
> Mar 13 20:54:46 ip-10-1-1-2 systemd\[1\]: Started OpenSearch Performance Analyzer.
> Mar 13 20:54:48 ip-10-1-1-2 performance-analyzer-agent-cli\[1735\]: Exception in thread "main" java.lang.IllegalArgumentException: cannot add context to list
> Mar 13 20:54:48 ip-10-1-1-2 performance-analyzer-agent-cli\[1735\]: at jdk.httpserver/sun.net.httpserver.ContextList.add(ContextList.java:37)
> Mar 13 20:54:48 ip-10-1-1-2 performance-analyzer-agent-cli\[1735\]: at jdk.httpserver/sun.net.httpserver.ServerImpl.createContext(ServerImpl.java:276)
> Mar 13 20:54:48 ip-10-1-1-2 performance-analyzer-agent-cli\[1735\]: at jdk.httpserver/sun.net.httpserver.HttpServerImpl.createContext(HttpServerImpl.java:74)
> Mar 13 20:54:48 ip-10-1-1-2 performance-analyzer-agent-cli\[1735\]: at jdk.httpserver/sun.net.httpserver.HttpServerImpl.createContext(HttpServerImpl.java:39)
> Mar 13 20:54:48 ip-10-1-1-2 performance-analyzer-agent-cli\[1735\]: at org.opensearch.performanceanalyzer.PerformanceAnalyzerApp.createClientServers(PerformanceAnalyzerApp.java:354)
> Mar 13 20:54:48 ip-10-1-1-2 performance-analyzer-agent-cli\[1735\]: at org.opensearch.performanceanalyzer.PerformanceAnalyzerApp.createClientServers(PerformanceAnalyzerApp.java:319)
> Mar 13 20:54:48 ip-10-1-1-2 performance-analyzer-agent-cli\[1735\]: at org.opensearch.performanceanalyzer.PerformanceAnalyzerApp.main(PerformanceAnalyzerApp.java:112)
> user@ip-10-1-1-2:~$
> \`\`\`
> 
> \*\*How can one reproduce the bug?\*\*
> Steps to reproduce the behavior:
> 1. Install OpenSearch 2.12.0 via DEB package on a Debian/Ubuntu host.
> 2. Evaluate status of the \`opensearch-performance-analyzer.service\`.
> 
> \*\*What is the expected behavior?\*\*
> The \`opensearch-performance-analyzer.service\` (\`opensearch-performance-analyzer-cli\` process) to start successfully without exception & ultimately respond to HTTP requests sent to its default socket-listener on port 9600.
> 
> \*\*What is your host/environment?\*\*
> - OS: Ubuntu 20.0.4.6 LTS
> - Version 2.12.0
> - Plugins
> - Nothing 'extra' was installed, only the plug-ins enabled by default with 2.12.0.
> 
> 
> OS: 
> 
> \*\*Do you have any screenshots?\*\*
> N/A, see output from \`systemctl\` in Description.
> 
> \*\*Do you have any additional context?\*\*
> This problem does not seem to exist in versions before 2.12.0 (ex: 2.11.1), as the \`opensearch-performance-analyzer.service\` functions as expected & is responsive to requests to its default socket-listener on Port 9600 in older versions.

---

<div class="post-metadata">

**Author:** ![BoL](https://avatars.discourse-cdn.com/v4/letter/b/aca169/32.png) [@BoL](https://forum.opensearch.org/u/BoL)\
**Post date:** [March 28, 2024, 9:40am UTC](https://forum.opensearch.org/t/opensearch-performance-analyzer-service-java-lang-illegalargumentexception-cannot-add-context-to-list/18365/3 "2024-03-28T09:40:10Z")

</div>

This issue actually prevents PerformanceAnalyzer from listening for any requests on port 9600, which makes it unusable. By looking at the sources it is an obvious issue, as the code tries to add the same handler 2 times so, the second attempt throws an exception which is not caught, so app is not working after that. The actual bug needs to be opened in : [GitHub - opensearch-project/performance-analyzer-rca: The Performance Analyzer RCA is a framework that builds on the Performance Analyzer engine to support root cause analysis (RCA) of performance and reliability problems for OpenSearch instances.](https://github.com/opensearch-project/performance-analyzer-rca)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/3/33547ea01a5b12dcca2958411d3edd97ae2ea8c1.png) [@system](https://forum.opensearch.org/u/system)\
**Post date:** [May 27, 2024, 9:40am UTC](https://forum.opensearch.org/t/opensearch-performance-analyzer-service-java-lang-illegalargumentexception-cannot-add-context-to-list/18365/4 "2024-05-27T09:40:50Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
