Skip to content

Commit

Permalink
Workaround G1 bug for JDK 22 and 22.0.1 (#108571)
Browse files Browse the repository at this point in the history
See https://bugs.openjdk.org/browse/JDK-8329528. The applied workaround
was suggested on the linked issue, and was tested and confirmed to avoid
the G1 bug.
  • Loading branch information
rjernst authored May 14, 2024
1 parent 589d927 commit b2bc951
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ static List<String> systemJvmOptions(Settings nodeSettings, final Map<String, St
maybeEnableNativeAccess(),
maybeOverrideDockerCgroup(distroType),
maybeSetActiveProcessorCount(nodeSettings),
maybeWorkaroundG1Bug(),
setReplayFile(distroType, isHotspot),
"-Djava.library.path=" + libraryPath,
"-Djna.library.path=" + libraryPath,
Expand Down Expand Up @@ -137,6 +138,17 @@ private static String maybeEnableNativeAccess() {
return "";
}

/*
* Only affects 22 and 22.0.1, see https://bugs.openjdk.org/browse/JDK-8329528
*/
private static String maybeWorkaroundG1Bug() {
Runtime.Version v = Runtime.version();
if (v.feature() == 22 && v.update() <= 1) {
return "-XX:+UnlockDiagnosticVMOptions -XX:G1NumCollectionsKeepPinned=10000000";
}
return "";
}

private static String findLibraryPath(Map<String, String> sysprops) {
// working dir is ES installation, so we use relative path here
Path platformDir = Paths.get("lib", "platform");
Expand Down
5 changes: 5 additions & 0 deletions docs/changelog/108571.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 108571
summary: Workaround G1 bug for JDK 22 and 22.0.1
area: Infra/CLI
type: bug
issues: []

0 comments on commit b2bc951

Please sign in to comment.