Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JVM Agent not compatible with -XX:+PerfDisableSharedMem #198

Closed
thobbs opened this issue May 22, 2015 · 11 comments
Closed

JVM Agent not compatible with -XX:+PerfDisableSharedMem #198

thobbs opened this issue May 22, 2015 · 11 comments

Comments

@thobbs
Copy link

@thobbs thobbs commented May 22, 2015

For some reason, the Jolokia agent does not appear to be compatible with the -XX:+PerfDisableSharedMem JVM option.

I'm testing this against Cassandra. When running with the option:

$ java -jar ~/Downloads/jolokia-jvm-1.3.0-agent.jar list
6826   /home/thobbs/Downloads/jolokia-jvm-1.3.0-agent.jar list

And when running without the option (no other changes):

$ java -jar ~/Downloads/jolokia-jvm-1.3.0-agent.jar list
7108   /home/thobbs/Downloads/jolokia-jvm-1.3.0-agent.jar list
6917   org.apache.cassandra.service.CassandraDaemon

Although I don't think it makes a difference, this is my Java version:

java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
@rhuss
Copy link
Owner

@rhuss rhuss commented May 23, 2015

The "list" command can only show the processes which comes out of com.sun.tools.attach.VirtualMachine.list() (see here how it is used in Jolokia).

It seems that adding the parameter will prevents the JVM to be included.

What you still try is to find out the process id and connect directly to the process with java -jar jolokia.jar <pid>. I guess, an error will occur but would be curious what kind of error ;-)

@rhuss
Copy link
Owner

@rhuss rhuss commented May 23, 2015

I'm afraid that I can't do much here from Jolokia's side. Its more a bug of the JVM, but since I'm using some 'non-official' API (in the com.sun namespace) I'm afraid that Oracle won't fix this, too. But would be worth a try.

And thanks for finding out, btw ;-)

@thobbs
Copy link
Author

@thobbs thobbs commented May 26, 2015

I was afraid that might be the answer. Thank you for taking the time to look into it anyway!

As you guessed, an error does occur if you try to connect to the process anyway:

$ java -jar jolokia-jvm-1.3.0-agent.jar list
29274   jolokia-jvm-1.3.0-agent.jar list
$ pgrep -f CassandraDaemon
29040
$ java -jar jolokia-jvm-1.3.0-agent.jar start 29040 --verbose
Illegal Argument (command: start) : Cannot attach to process-ID 29040.
See --help for possible reasons.
java.lang.IllegalArgumentException: Cannot attach to process-ID 29040.
See --help for possible reasons.
    at org.jolokia.jvmagent.client.util.VirtualMachineHandler.getProcessId(VirtualMachineHandler.java:171)
    at org.jolokia.jvmagent.client.util.VirtualMachineHandler.attachVirtualMachine(VirtualMachineHandler.java:66)
    at org.jolokia.jvmagent.client.AgentLauncher.main(AgentLauncher.java:57)
@thobbs thobbs closed this May 26, 2015
@rhuss
Copy link
Owner

@rhuss rhuss commented May 26, 2015

Sorry for that ;-(. Some last note, which often gets overseen: You need to run under the exact same UID as the JVM process is running with. Strangely, it is not enough to call this under UID 0. This is probably not the case here, just want to mention it ;-)

@jhermann
Copy link
Contributor

@jhermann jhermann commented Jun 2, 2015

BTW, the UID restriction got introduced not too long ago with updates of Java8 (I think 8u11 still worked with UID 0, and 8u40 definitely doesn't anymore).

@rhuss
Copy link
Owner

@rhuss rhuss commented Aug 31, 2015

I have the UID also for Java 7 (however don't know exactly at which version).

@ghost
Copy link

@ghost ghost commented Nov 11, 2015

Just want to say this thread really helped me out a lot. Thanks guys.

@apoorv007
Copy link

@apoorv007 apoorv007 commented May 17, 2017

I wonder why is the agent not able to connect when directly given a PID. This seems like an issue on agent rather than JVM, since a JMX client like JConsole is able to connect when directly given a PID.

I believe that -XX:+PerfDisableSharedMem option only hampers the discovery of available java processes. I see that in both cases (i.e when PID is given OR when process name regex is given), VirtualMachineHandler.listProcesses() is invoked. Shouldn't the agent just try to connect when given a PID? Please let me know if I am missing out something.

Thanks

@rhuss
Copy link
Owner

@rhuss rhuss commented May 17, 2017

Actually, you are right, since the agent doesn't even try to attach to the PID if it is not listable, in order to give a meaningful error description. See here where this check happens:

private boolean isAttachable(String pPid) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {

This was also because I (falsely ?) assumed that every process which can be attached to is also listed.

I can move this check up and try nevertheless. Thanks for spotting this.

rhuss added a commit that referenced this issue May 17, 2017
Now it will be always tried to connect, even when the PID is not listed.
Also an internal retry to retrieve the agent URL as it seems there is some delay
in launching it.
@apoorv007
Copy link

@apoorv007 apoorv007 commented May 17, 2017

Thanks for the quick fix. When will 1.3.7 get released?

@rhuss
Copy link
Owner

@rhuss rhuss commented May 17, 2017

There's no schedule yet, but I hope until this end of this month.

XN137 added a commit to XN137/cassandra-dtest that referenced this issue Sep 24, 2020
…m workaround

rhuss/jolokia#198 has been fixed since jolokia 1.3.7,
so there is no reason to keep the remove_perf_disable_shared_mem workaround anymore.
It is assumed that the '-XX:-PerfDisableSharedMem' usage was added exclusively for
jolokia as well.

patch by Christopher Lambert; reviewed by Mick Semb Wever
XN137 added a commit to XN137/cassandra-dtest that referenced this issue Sep 24, 2020
…m workaround

rhuss/jolokia#198 has been fixed since jolokia 1.3.7,
so there is no reason to keep the remove_perf_disable_shared_mem workaround anymore.
It is assumed that the '-XX:-PerfDisableSharedMem' usage was added exclusively for
jolokia as well.

patch by Christopher Lambert; reviewed by Mick Semb Wever
XN137 added a commit to XN137/cassandra-dtest that referenced this issue Sep 24, 2020
…m workaround

rhuss/jolokia#198 has been fixed since jolokia 1.3.7,
so there is no reason to keep the remove_perf_disable_shared_mem workaround anymore.
It is assumed that the '-XX:-PerfDisableSharedMem' usage was added exclusively for
jolokia as well.

patch by Christopher Lambert; reviewed by Mick Semb Wever
michaelsembwever added a commit to apache/cassandra-dtest that referenced this issue Sep 24, 2020
…m workaround

rhuss/jolokia#198 has been fixed since jolokia 1.3.7,
so there is no reason to keep the remove_perf_disable_shared_mem workaround anymore.
It is assumed that the '-XX:-PerfDisableSharedMem' usage was added exclusively for
jolokia as well.

patch by Christopher Lambert; reviewed by Mick Semb Wever
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants