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

All requests to DynamoDB fail with Connection pool shut down #5567

Open
IDUN-BogdanPi opened this issue Sep 6, 2024 · 4 comments
Open

All requests to DynamoDB fail with Connection pool shut down #5567

IDUN-BogdanPi opened this issue Sep 6, 2024 · 4 comments
Assignees
Labels
bug This issue is a bug. p3 This is a minor priority issue

Comments

@IDUN-BogdanPi
Copy link

Describe the bug

Without any apparent reason, sometimes I get this exception java.lang.IllegalStateException: Connection pool shut down and all requests to DynamoDB fail.

I am using DynamoDB Enhanced Client:

    <dependency>
        <groupId>software.amazon.awssdk</groupId>
        <artifactId>dynamodb-enhanced</artifactId>
    </dependency>

And have a single client running in the app configured with Spring @bean

  @Bean
    public DynamoDbEnhancedClient dynamoDbClient(
            @Value("${dynamodb.use-localstack:false}") boolean useLocalStack,
            @Value("${LOCALSTACK_CUSTOM_ENDPOINT:}") String customEndpoint) {
        DynamoDbClientBuilder builder = DynamoDbClient.builder();

        if (useLocalStack) {
            // Point to LocalStack endpoint
            builder.endpointOverride(URI.create(customEndpoint))
                    .region(Region.of("eu-central-1")); // LocalStack doesn't care much about the region
        } else {
            // AWS Configuration
            builder.region(Region.EU_CENTRAL_1);
        }

        DynamoDbClient dynamoDbClient = builder.build();
        DynamoDbEnhancedClient enhancedClient = DynamoDbEnhancedClient.builder()
                .dynamoDbClient(dynamoDbClient)
                .build();

        return enhancedClient;
    }

Expected Behavior

I expect that no exceptions arise.

Current Behavior

java.lang.IllegalStateException: Connection pool shut down
	at org.apache.http.util.Asserts.check(Asserts.java:34)
	at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.requestConnection(PoolingHttpClientConnectionManager.java:269)
	at software.amazon.awssdk.http.apache.internal.conn.ClientConnectionManagerFactory$DelegatingHttpClientConnectionManager.requestConnection(ClientConnectionManagerFactory.java:75)
	at software.amazon.awssdk.http.apache.internal.conn.ClientConnectionManagerFactory$InstrumentedHttpClientConnectionManager.requestConnection(ClientConnectionManagerFactory.java:57)
	...

stacktrace_2.txt
stacktrace_1.txt

Reproduction Steps

This happens very rarely, without an apparent reason. Sometimes even months in between. I could not find what causes it.

Possible Solution

No response

Additional Information/Context

I am performing some queries in Async context using completable future:

CompletableFuture<Void> f = CompletableFuture
                        .runAsync(()

AWS Java SDK version used

software.amazon.awssdk 2.21.37

JDK version used

amazoncorretto:21.0.1

Operating System and version

amazoncorretto:21.0.1

@IDUN-BogdanPi IDUN-BogdanPi added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 6, 2024
@debora-ito
Copy link
Member

Check our Troubleshooting Guide:

FAQ: How do I fix "java.lang.IllegalStateException: Connection pool shut down" error?

@debora-ito debora-ito added closing-soon This issue will close in 4 days unless further comments are made. p3 This is a minor priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Sep 6, 2024
@debora-ito debora-ito self-assigned this Sep 6, 2024
@IDUN-BogdanPi
Copy link
Author

Thanks for the reply. I did check everything in the docs. There don't seem to be any Errors thrown. I checked the memory usage and it appeared to be relatively low.
DefaultCredentialsProvider we don't use. The SDK lifecycle is managed by Spring via @bean.

So I'm out of ideas. I'll keep digging / profiling, but if there is anything else I could try, please let me know.

@github-actions github-actions bot removed the closing-soon This issue will close in 4 days unless further comments are made. label Sep 9, 2024
@debora-ito
Copy link
Member

The only thing I can think of is Spring Bean may be automatically calling close(), see Bean#destroyMethod(). Try disabling the destroy method.

@debora-ito debora-ito added the closing-soon This issue will close in 4 days unless further comments are made. label Sep 10, 2024
@IDUN-BogdanPi
Copy link
Author

Thanks! I'll try that.

@github-actions github-actions bot removed the closing-soon This issue will close in 4 days unless further comments are made. label Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p3 This is a minor priority issue
Projects
None yet
Development

No branches or pull requests

2 participants