You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When starting the application service, the program will need to get many secrets from AWS SecretsManager.
To improve the performance, the program will load all secrets in a thread pool.
The issue is found when creating the ExecutorService instance with Executors.newVirtualThreadPerTaskExecutor() with JDK 22/23 Linux. When the number of virtual threads >=8, all threads hang for a long time (>30 seconds).
Tested following cases and they all work fine:
the number of virtual threads <8;
change to use Executors.newFixedThreadPool(20) with JDK 22/23 Linux;
All Windows JDK 21/22/23 work fine with the virtual threads.
Linux JDK 21 (openjdk-21.0.2_linux-x64_bin.tar.gz) works fine.
To Reproduce
Steps to reproduce:
Run the program as below:
importjava.util.ArrayList;
importjava.util.List;
importjava.util.concurrent.Executors;
importjava.util.concurrent.TimeUnit;
importcom.amazonaws.secretsmanager.caching.SecretCache;
publicclassAWSSecretCacheXTest {
privatestaticfinalFormattingLoggerLOG = FormattingLogger.getLogger(AWSSecretCacheXTest.class);
publicstaticvoidmain(String[] args) {
finalSecretCachecache = newSecretCache();
// Note: the problem can be reproduced when the number of secrets >= 8.List<String> secretKeys = getSecretKeys();
// The virtual thread has problem in JDK 22/23 Linux.varexecutor = Executors.newVirtualThreadPerTaskExecutor();
// var executor = Executors.newFixedThreadPool(20); // this works fine in JDK 22/23 Linuxtry {
for (StringsecretKey : secretKeys) {
executor.submit(() -> {
try {
cache.getSecretString(secretKey);
} catch (Throwablee) {
LOG.error("Failed to get secret key '%s'.", e, secretKey);
}
});
}
} finally {
executor.shutdown();
try {
if (!executor.awaitTermination(20, TimeUnit.SECONDS)) {
executor.shutdownNow();
}
} catch (InterruptedExceptione) {
executor.shutdownNow();
}
}
}
staticList<String> getSecretKeys() {
List<String> secretKeys = newArrayList<>();
secretKeys.add("secret01");
secretKeys.add("secret02");
// ...secretKeys.add("secret09");
returnsecretKeys;
}
}
Expected behavior
The SecretCache.getSecretString() method should work when using virtual threads and JDK 22/23 Linux.
Environment
OS: amazonlinux:2,
Java Version: JDK 22/23 Linux, (amazon-corretto-23.0.0.37.1-linux-x64.tar.gz, openjdk-23_linux-x64_bin.tar.gz and openjdk-22.0.2_linux-x64_bin.tar.gz)
AWS SDK version: latest version 2.28.6.
aws-secretsmanager-caching-java version: 2.0.0.
Additional context
N/A
The text was updated successfully, but these errors were encountered:
Describe the bug
When starting the application service, the program will need to get many secrets from AWS SecretsManager.
To improve the performance, the program will load all secrets in a thread pool.
The issue is found when creating the ExecutorService instance with
Executors.newVirtualThreadPerTaskExecutor()
with JDK 22/23 Linux. When the number of virtual threads >=8, all threads hang for a long time (>30 seconds).Tested following cases and they all work fine:
Executors.newFixedThreadPool(20)
with JDK 22/23 Linux;To Reproduce
Steps to reproduce:
Run the program as below:
Expected behavior
The SecretCache.getSecretString() method should work when using virtual threads and JDK 22/23 Linux.
Environment
OS: amazonlinux:2,
Java Version: JDK 22/23 Linux, (amazon-corretto-23.0.0.37.1-linux-x64.tar.gz, openjdk-23_linux-x64_bin.tar.gz and openjdk-22.0.2_linux-x64_bin.tar.gz)
AWS SDK version: latest version 2.28.6.
aws-secretsmanager-caching-java version: 2.0.0.
Additional context
N/A
The text was updated successfully, but these errors were encountered: