Changing GC settings in EAP on Openshift gives error "Conflicting collector option used"
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 7.x for OpenShift
- 8.x for OpenShift
- JBoss Web Server
- 3.x for OpenShift
- 5.x for OpenShift
Issue
- Changing garbage collection option using command
oc env dc/demoeap JAVA_OPTS_APPEND=-XX:+UseG1GCin JBoss EAP on Openshift, pods shows errorConflicting collector option used. - How do I switch the default GC strategy from
-XX:-UseParallelOldGCto-XX:+UseG1GC/-XX:+UseConcMarkSweepGC/-XX:+UseSerialGC?
Resolution
EAP containers:
| EAP image | Procedure |
|---|---|
jboss-eap-7/eap71-openshift:1.4-6(later) | Set the collector via GC_CONTAINER_OPTIONS |
jboss-eap-7/eap71-openshift:1.4-6(previous images) | Disable ParallelGC and set new GC via JAVA_OPTS_APPEND="-XX:-UseParallelOldGC -XX:+UseG1GC" |
Example jboss-eap-7/eap71-openshift:1.4-6 (upper):
From jboss-eap-7/eap71-openshift:1.4-6, environment variable GC_CONTAINER_OPTIONS is introduced to switch GC strategy from -XX:+UseParallelOldGC as default. This feature is implemented by Content from issues.jboss.org is not included.CLOUD-2286:
oc set env dc/demoeap GC_CONTAINER_OPTIONS="-XX:+UseG1GC"
deploymentconfig.apps.openshift.io/demoeap updated
Example jboss-eap-7/eap71-openshift:1.4-6 (lower):
Previous versions may require disabling the previously enabled GC option or default garbage collector, and enable the required GC option (below disable UseParallelOldGC and enable G1GC):
oc set env dc/eap-app JAVA_OPTS_APPEND="-XX:-UseParallelOldGC -XX:+UseG1GC"
deploymentconfig.apps.openshift.io/eap-app updated
In eap71-openshift:1.4-6 or later and subsequent minor versions of EAP such as 7.2/7.3/7.4, both JAVA_OPTS_APPEND and GC_CONTAINER_OPTIONS are env variables available to switch GC strategy. Using this option there is not need to disable parallel in fact.
EAP 8:
For EAP 8, the process will be relying on OpenJDK fully settings - not its own scripts and therefore ParallelGC comes by default, use GC_CONTAINER_OPTIONS for replacing it. Find more details in Differences in the default heap settings between JBoss EAP 7 and JBoss EAP 8 for OpenShift.
JWS containers:
From JWS versions below and later, environment variable GC_CONTAINER_OPTIONS is introduced to switch GC strategy from -XX:+UseParallelOldGC as default. This feature is implemented by This content is not included.CLOUD-2941. Other non-GC options can be set with CATALINA_OPTS_APPEND per How to append JVM options to JWS for OpenShift. Details:
jboss-webserver-3/webserver31-tomcat7-openshift:1.3-9jboss-webserver-3/webserver31-tomcat8-openshift:1.3-9jboss-webserver-5/webserver50-tomcat9-openshift:1.1-2
Root Cause
The JVM can only use one garbage collector at time - meaning one cannot use Parallel+G1GC at the same time. Previous versions of java would allow multiple garbage collector one for each generation - that's not the case for OpenJDK 7/8/11/17.
Therefore one needs to remove other conflicting gc collectors in case multiple are being used: ParallelGC and G1GC for example. However, later images introduced specifically GC_CONTAINER_OPTIONS to be used for this matter.
Diagnostic Steps
- oc set env dc/$dcname GC_CONTAINER_OPTIONS="-XX:+UseG1GC"
- oc get dc/$dcname -o yaml | grep -B 5 -A 5 UseG1GC
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.