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

[Backport] [2.x] Update bundled JDK to JDK-21.0.1 (#10576) #11003

Merged
merged 4 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,12 @@
test.systemProperty("java.locale.providers", "SPI,JRE");
} else {
test.systemProperty("java.locale.providers", "SPI,COMPAT");
test.jvmArgs("--illegal-access=warn");
if (test.getJavaVersion().compareTo(JavaVersion.VERSION_17) < 0) {
test.jvmArgs("--illegal-access=warn");

Check warning on line 115 in buildSrc/src/main/java/org/opensearch/gradle/OpenSearchTestBasePlugin.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/OpenSearchTestBasePlugin.java#L115

Added line #L115 was not covered by tests
}
}
if (test.getJavaVersion().compareTo(JavaVersion.VERSION_17) > 0) {
test.jvmArgs("-Djava.security.manager=allow");

Check warning on line 119 in buildSrc/src/main/java/org/opensearch/gradle/OpenSearchTestBasePlugin.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/OpenSearchTestBasePlugin.java#L119

Added line #L119 was not covered by tests
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@
import java.util.stream.Stream;

public class DistroTestPlugin implements Plugin<Project> {
private static final String SYSTEM_JDK_VERSION = "11.0.20+8";
private static final String SYSTEM_JDK_VERSION = "17.0.9+9";
private static final String SYSTEM_JDK_VENDOR = "adoptium";
private static final String GRADLE_JDK_VERSION = "17.0.8+7";
private static final String GRADLE_JDK_VERSION = "17.0.9+9";
private static final String GRADLE_JDK_VENDOR = "adoptium";

// all distributions used by distro tests. this is temporary until tests are per distribution
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/version.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ opensearch = 2.12.0
lucene = 9.8.0

bundled_jdk_vendor = adoptium
bundled_jdk = 17.0.8+7
bundled_jdk = 21.0.1+12
peternied marked this conversation as resolved.
Show resolved Hide resolved

# optional dependencies
spatial4j = 0.7
Expand Down
2 changes: 1 addition & 1 deletion distribution/src/config/jvm.options
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ ${error.file}

# JDK 20+ Incubating Vector Module for SIMD optimizations;
# disabling may reduce performance on vector optimized lucene
20:--add-modules=jdk.incubator.vector
20-:--add-modules=jdk.incubator.vector

# HDFS ForkJoinPool.common() support by SecurityManager
-Djava.util.concurrent.ForkJoinPool.common.threadFactory=org.opensearch.secure_sm.SecuredForkJoinWorkerThreadFactory
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,21 @@
// log4j 2
"-Dlog4j.shutdownHookEnabled=false",
"-Dlog4j2.disable.jmx=true",

// security manager
allowSecurityManagerOption(),

Check warning on line 81 in distribution/tools/launchers/src/main/java/org/opensearch/tools/launchers/SystemJvmOptions.java

View check run for this annotation

Codecov / codecov/patch

distribution/tools/launchers/src/main/java/org/opensearch/tools/launchers/SystemJvmOptions.java#L81

Added line #L81 was not covered by tests
javaLocaleProviders()
)
).stream().filter(e -> e.isEmpty() == false).collect(Collectors.toList());
}

private static String allowSecurityManagerOption() {
if (Runtime.version().feature() > 17) {
return "-Djava.security.manager=allow";

Check warning on line 89 in distribution/tools/launchers/src/main/java/org/opensearch/tools/launchers/SystemJvmOptions.java

View check run for this annotation

Codecov / codecov/patch

distribution/tools/launchers/src/main/java/org/opensearch/tools/launchers/SystemJvmOptions.java#L89

Added line #L89 was not covered by tests
} else {
return "";

Check warning on line 91 in distribution/tools/launchers/src/main/java/org/opensearch/tools/launchers/SystemJvmOptions.java

View check run for this annotation

Codecov / codecov/patch

distribution/tools/launchers/src/main/java/org/opensearch/tools/launchers/SystemJvmOptions.java#L91

Added line #L91 was not covered by tests
}
}

private static String maybeShowCodeDetailsInExceptionMessages() {
if (Runtime.version().feature() >= 14) {
return "-XX:+ShowCodeDetailsInExceptionMessages";
Expand Down
27 changes: 17 additions & 10 deletions libs/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,23 @@ tasks.named('forbiddenApisMain').configure {
tasks.named("thirdPartyAudit").configure {
ignoreMissingClasses(
// from log4j
'org.osgi.framework.Bundle',
'org.osgi.framework.BundleActivator',
'org.osgi.framework.BundleContext',
'org.osgi.framework.BundleEvent',
'org.osgi.framework.FrameworkUtil',
'org.osgi.framework.ServiceReference',
'org.osgi.framework.ServiceRegistration',
'org.osgi.framework.SynchronousBundleListener',
'org.osgi.framework.wiring.BundleWire',
'org.osgi.framework.wiring.BundleWiring'
*[
'org.osgi.framework.Bundle',
'org.osgi.framework.BundleActivator',
'org.osgi.framework.BundleContext',
'org.osgi.framework.BundleEvent',
'org.osgi.framework.SynchronousBundleListener',
'org.osgi.framework.wiring.BundleWire',
'org.osgi.framework.wiring.BundleWiring',
] + (BuildParams.runtimeJavaVersion < JavaVersion.VERSION_20) ? [] : [
'jdk.incubator.vector.ByteVector',
'jdk.incubator.vector.FloatVector',
'jdk.incubator.vector.IntVector',
'jdk.incubator.vector.ShortVector',
'jdk.incubator.vector.Vector',
'jdk.incubator.vector.VectorOperators',
'jdk.incubator.vector.VectorSpecies'
]
)
}

Expand Down
13 changes: 12 additions & 1 deletion server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ tasks.named("processResources").configure {

tasks.named("thirdPartyAudit").configure {
ignoreMissingClasses(
*[
// from com.fasterxml.jackson.dataformat.yaml.YAMLMapper (jackson-dataformat-yaml)
'com.fasterxml.jackson.databind.ObjectMapper',

Expand Down Expand Up @@ -385,7 +386,17 @@ tasks.named("thirdPartyAudit").configure {
'org.slf4j.Logger',
'org.slf4j.LoggerFactory',
'reactor.blockhound.BlockHound$Builder',
'reactor.blockhound.integration.BlockHoundIntegration'
'reactor.blockhound.integration.BlockHoundIntegration',
'com.google.common.geometry.S2LatLng'
] + (BuildParams.runtimeJavaVersion < JavaVersion.VERSION_20) ? [] : [
'jdk.incubator.vector.ByteVector',
'jdk.incubator.vector.FloatVector',
'jdk.incubator.vector.IntVector',
'jdk.incubator.vector.ShortVector',
'jdk.incubator.vector.Vector',
'jdk.incubator.vector.VectorOperators',
'jdk.incubator.vector.VectorSpecies'
]
)
ignoreViolations(
'com.google.protobuf.MessageSchema',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@

import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.Matchers.not;
import static org.junit.Assume.assumeThat;

/**
* Tests relating to the loss of the cluster-manager.
Expand All @@ -71,6 +73,7 @@ public class ClusterManagerDisruptionIT extends AbstractDisruptionTestCase {
*/
public void testClusterManagerNodeGCs() throws Exception {
List<String> nodes = startCluster(3);
assumeThat("Thread::resume / Thread::suspend are not supported anymore", Runtime.version(), lessThan(Runtime.Version.parse("20")));

String oldClusterManagerNode = internalCluster().getClusterManagerName();
// a very long GC, but it's OK as we remove the disruption when it has had an effect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@

import static java.util.Collections.singleton;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.lessThan;
import static org.junit.Assume.assumeThat;

/**
* Tests relating to the loss of the cluster-manager, but which work with the default fault detection settings which are rather lenient and will
Expand Down Expand Up @@ -195,6 +197,8 @@ private void testFollowerCheckerAfterClusterManagerReelection(NetworkLinkDisrupt
* following another elected cluster-manager node. These nodes should reject this cluster state and prevent them from following the stale cluster-manager.
*/
public void testStaleClusterManagerNotHijackingMajority() throws Exception {
assumeThat("Thread::resume / Thread::suspend are not supported anymore", Runtime.version(), lessThan(Runtime.Version.parse("20")));

final List<String> nodes = internalCluster().startNodes(
3,
Settings.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public abstract class BaseFuture<V> implements Future<V> {
*
* @throws InterruptedException if the current thread was interrupted before
* or during the call (optional but recommended).
* @throws CancellationException {@inheritDoc}
* @throws CancellationException if the computation was cancelled
*/
@Override
public V get(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException, ExecutionException {
Expand All @@ -96,7 +96,7 @@ public V get(long timeout, TimeUnit unit) throws InterruptedException, TimeoutEx
*
* @throws InterruptedException if the current thread was interrupted before
* or during the call (optional but recommended).
* @throws CancellationException {@inheritDoc}
* @throws CancellationException if the computation was cancelled
*/
@Override
public V get() throws InterruptedException, ExecutionException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,30 @@
public class MockSinglePrioritizingExecutor extends PrioritizedOpenSearchThreadPoolExecutor {

public MockSinglePrioritizingExecutor(String name, DeterministicTaskQueue deterministicTaskQueue, ThreadPool threadPool) {
super(name, 0, 1, 0L, TimeUnit.MILLISECONDS, r -> new Thread() {
@Override
public void start() {
deterministicTaskQueue.scheduleNow(new Runnable() {
@Override
public void run() {
try {
r.run();
} catch (KillWorkerError kwe) {
// hacks everywhere
}
super(name, 0, 1, 0L, TimeUnit.MILLISECONDS, r -> {
// This executor used to override Thread::start method so the actual runnable is
// being scheduled in the scope of current thread of execution. In JDK-19, the Thread::start
// is not called anymore (https://bugs.openjdk.org/browse/JDK-8292027) and there is no
// suitable option to alter the executor's behavior in the similar way. The closest we
// could get to is to schedule the runnable once the ThreadFactory is being asked to
// allocate the new thread.
deterministicTaskQueue.scheduleNow(new Runnable() {
@Override
public void run() {
try {
r.run();
} catch (KillWorkerError kwe) {
// hacks everywhere
}
}

@Override
public String toString() {
return r.toString();
}
});
}
@Override
public String toString() {
return r.toString();
}
});

return new Thread(() -> {});
}, threadPool.getThreadContext(), threadPool.scheduler());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.lessThan;
import static org.junit.Assume.assumeThat;

public class LongGCDisruptionTests extends OpenSearchTestCase {

Expand All @@ -65,6 +67,8 @@ public void executeLocked(Runnable r) {
}

public void testBlockingTimeout() throws Exception {
assumeThat("Thread::resume / Thread::suspend are not supported anymore", Runtime.version(), lessThan(Runtime.Version.parse("20")));

final String nodeName = "test_node";
LongGCDisruption disruption = new LongGCDisruption(random(), nodeName) {
@Override
Expand Down Expand Up @@ -125,6 +129,8 @@ protected long getSuspendingTimeoutInMillis() {
* but does keep retrying until all threads can be safely paused
*/
public void testNotBlockingUnsafeStackTraces() throws Exception {
assumeThat("Thread::resume / Thread::suspend are not supported anymore", Runtime.version(), lessThan(Runtime.Version.parse("20")));

final String nodeName = "test_node";
LongGCDisruption disruption = new LongGCDisruption(random(), nodeName) {
@Override
Expand Down Expand Up @@ -179,6 +185,8 @@ protected Pattern[] getUnsafeClasses() {
}

public void testBlockDetection() throws Exception {
assumeThat("Thread::resume / Thread::suspend are not supported anymore", Runtime.version(), lessThan(Runtime.Version.parse("20")));

final String disruptedNodeName = "disrupted_node";
final String blockedNodeName = "blocked_node";
CountDownLatch waitForBlockDetectionResult = new CountDownLatch(1);
Expand Down
Loading