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

Plugin script fails when memory parameters are defined in environment file #12479

Closed
jaymode opened this issue Jul 27, 2015 · 10 comments
Closed
Assignees
Labels
>bug :Core/Infra/Plugins Plugin API and infrastructure

Comments

@jaymode
Copy link
Member

jaymode commented Jul 27, 2015

The plugin script fails to initialize when the the environment file (for DEB installations, /etc/default/elasticsearch) is sourced and contains memory parameters in ES_JAVA_OPTS such as a larger new size.

Example output:

$ bin/plugin -r pluginname
Error occurred during initialization of VM
Too small initial heap for new size specified

This is caused by the hardcoded Xmx and Xms parameters in the plugin script. Removing the hardcoded values allows the script to execute successfully.

We may be able to just use the default JVM values here instead of hardcoding these values.

@jaymode jaymode added >bug :Core/Infra/Plugins Plugin API and infrastructure labels Jul 27, 2015
@clintongormley clintongormley changed the title plugin script fails when memory parameters are defined in environment file Plugin script fails when memory parameters are defined in environment file Jul 27, 2015
@spinscale
Copy link
Contributor

steps to reproduce:

  • You need java 1.7, does not happen with java 1.8
  • set ES_JAVA_OPTS="-XX:NewSize=256m" in /etc/default/elasticsearch

Then call the plugin manager like

# /usr/share/elasticsearch/bin/plugin
Error occurred during initialization of VM
Too small initial heap for new size specified

I am not sure if it is a good idea to remove those values, because this means, that you can potentially run the plugin manager with the same heap configured than your elasticsearch process, given you used -Xms and -Xmx instead of ES_HEAP_SIZE, which is never used in the plugin manager

As java 7 is EOL and it works with Java8, I am currently leaning towards closing this, as soon as I figured out, what actually happens in Java8 - as in what values are really getting used and which get ignored.

Update: No need to have a package installed, you can simply use JAVA_OPTS on osx as well and call bin/plugin

@spinscale
Copy link
Contributor

So, using a small java class, that basically prints out ManagementFactory.getMemoryMXBean().getHeapMemoryUsage() shows, that java8 is doing the right thing and respects Xmx and Xms

java8:

# java -XX:NewSize=256m -Xmx64m -Xms16m Foo
init = 16777216(16384K) used = 1311456(1280K) committed = 15204352(14848K) max = 45613056(44544K)
# java -Xmx64m -Xms16m Foo
init = 16777216(16384K) used = 872696(852K) committed = 16252928(15872K) max = 59768832(58368K)

java7 (obviously)

# java -XX:NewSize=256m -Xmx64m -Xms16m Foo
Error occurred during initialization of VM
Too small initial heap for new size specified
# java -Xmx64m -Xms16m Foo
init = 16777216(16384K) used = 480376(469K) committed = 16777216(16384K) max = 59768832(58368K)

@jaymode objections against leaving as it is to prevent accidentally crazy high heaps for the plugin manager if people configure -Xmx in the JAVA_OPTS or ES_JAVA_OPTS for Elasticsearch itself?

@jaymode
Copy link
Member Author

jaymode commented Aug 10, 2015

I'm ok with leaving memory values specified.

I think the question is can we do anything to make an error less likely if memory values are configured in that option? I can't think of a good option since sourcing the config files has value. Maybe we don't use ES_JAVA_OPTS and introduce a CLI_JAVA_OPTS or something?

@spinscale
Copy link
Contributor

this also raises an interesting point, if we want to merge the plugin manager into the BootstrapCliParser as this means, both have to run with the same memory settings, which might be bad...

@spinscale
Copy link
Contributor

so we would need ES_JAVA_OPTS, PLUGIN_JAVA_OPTS and COMMON_JAVA_OPTS or are two options sufficient? Just mapping it out... given the single hit we had with this, I would postpone it for now

@rjernst
Copy link
Member

rjernst commented Aug 10, 2015

why doe the plugin manager need java opts at all?

@jaymode
Copy link
Member Author

jaymode commented Aug 10, 2015

We've used the ES_JAVA_OPTS as a way to specify a custom conf directory/file location. That was before we started reading those files.

I think removing both JAVA_OPTS and ES_JAVA_OPTS is ok since we:

  1. read the environment configuration files for RPM/DEB now
  2. have the ability to specify the options with -- syntax

@rjernst
Copy link
Member

rjernst commented Aug 10, 2015

Regardless of whether we remove those env settings, I don't see why plugin manager needs them. This is a tiny program that just installs/removes/lists plugins. It should not require setting eg heap size or crazy other java options.

@jaymode
Copy link
Member Author

jaymode commented Aug 10, 2015

Regardless of whether we remove those env settings, I don't see why plugin manager needs them.

+1

@spinscale
Copy link
Contributor

so, removing JAVA_OPTS and ES_JAVA_OPTS settings still pass all integration tests... and works under CentOS, going to create a PR after testing the debian package

spinscale added a commit to spinscale/elasticsearch that referenced this issue Sep 15, 2015
... and run as client VM.

Reasoning: When calling the plugin manager on java 7 with additional JAVA_OPTS
that change heap configuration compared to what is set at the plugin
manager shell script. This resulted in errors.

This commit removes the JAVA_OPTS and ES_JAVA_OPTS from the plugin
manager call to prevent those settings.

Closes elastic#12479
spinscale added a commit that referenced this issue Sep 15, 2015
... and run as client VM.

Reasoning: When calling the plugin manager on java 7 with additional JAVA_OPTS
that change heap configuration compared to what is set at the plugin
manager shell script. This resulted in errors.

This commit removes the JAVA_OPTS and ES_JAVA_OPTS from the plugin
manager call to prevent those settings.

Closes #12479
spinscale added a commit that referenced this issue Sep 15, 2015
... and run as client VM.

Reasoning: When calling the plugin manager on java 7 with additional JAVA_OPTS
that change heap configuration compared to what is set at the plugin
manager shell script. This resulted in errors.

This commit removes the JAVA_OPTS and ES_JAVA_OPTS from the plugin
manager call to prevent those settings.

Closes #12479
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Core/Infra/Plugins Plugin API and infrastructure
Projects
None yet
Development

No branches or pull requests

3 participants