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

[BugFix] Fix "Connection pool shut down" in S3AFileSystem #50816

Merged
merged 8 commits into from
Sep 24, 2024

Conversation

Smith-Cruise
Copy link
Contributor

@Smith-Cruise Smith-Cruise commented Sep 6, 2024

Why I'm doing:

Fix the below error when using S3AFileSystem + aws.s3.use_aws_sdk_default_behavior=true.

Caused by: java.lang.IllegalStateException: Connection pool shut down
	at software.amazon.awssdk.thirdparty.org.apache.http.util.Asserts.check(Asserts.java:34) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.thirdparty.org.apache.http.impl.conn.PoolingHttpClientConnectionManager.requestConnection(PoolingHttpClientConnectionManager.java:269) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.http.apache.internal.conn.ClientConnectionManagerFactory$DelegatingHttpClientConnectionManager.requestConnection(ClientConnectionManagerFactory.java:75) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.http.apache.internal.conn.ClientConnectionManagerFactory$InstrumentedHttpClientConnectionManager.requestConnection(ClientConnectionManagerFactory.java:57) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.thirdparty.org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:176) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.thirdparty.org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.thirdparty.org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.thirdparty.org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.thirdparty.org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.http.apache.internal.impl.ApacheSdkHttpClient.execute(ApacheSdkHttpClient.java:72) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.http.apache.ApacheHttpClient.execute(ApacheHttpClient.java:254) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.http.apache.ApacheHttpClient.access$500(ApacheHttpClient.java:104) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.http.apache.ApacheHttpClient$1.call(ApacheHttpClient.java:231) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.http.apache.ApacheHttpClient$1.call(ApacheHttpClient.java:228) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.util.MetricUtils.measureDurationUnsafe(MetricUtils.java:99) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.executeHttpRequest(MakeHttpRequestStage.java:79) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.execute(MakeHttpRequestStage.java:57) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.execute(MakeHttpRequestStage.java:40) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallAttemptTimeoutTrackingStage.execute(ApiCallAttemptTimeoutTrackingStage.java:72) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallAttemptTimeoutTrackingStage.execute(ApiCallAttemptTimeoutTrackingStage.java:42) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.stages.TimeoutExceptionHandlingStage.execute(TimeoutExceptionHandlingStage.java:78) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.stages.TimeoutExceptionHandlingStage.execute(TimeoutExceptionHandlingStage.java:40) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallAttemptMetricCollectionStage.execute(ApiCallAttemptMetricCollectionStage.java:55) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallAttemptMetricCollectionStage.execute(ApiCallAttemptMetricCollectionStage.java:39) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage.execute(RetryableStage.java:81) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage.execute(RetryableStage.java:36) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.StreamManagingStage.execute(StreamManagingStage.java:56) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.StreamManagingStage.execute(StreamManagingStage.java:36) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallTimeoutTrackingStage.executeWithTimer(ApiCallTimeoutTrackingStage.java:80) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallTimeoutTrackingStage.execute(ApiCallTimeoutTrackingStage.java:60) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallTimeoutTrackingStage.execute(ApiCallTimeoutTrackingStage.java:42) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallMetricCollectionStage.execute(ApiCallMetricCollectionStage.java:50) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallMetricCollectionStage.execute(ApiCallMetricCollectionStage.java:32) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ExecutionFailureExceptionReportingStage.execute(ExecutionFailureExceptionReportingStage.java:37) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ExecutionFailureExceptionReportingStage.execute(ExecutionFailureExceptionReportingStage.java:26) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.http.AmazonSyncHttpClient$RequestExecutionBuilderImpl.execute(AmazonSyncHttpClient.java:224) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.invoke(BaseSyncClientHandler.java:103) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.doExecute(BaseSyncClientHandler.java:173) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.lambda$execute$1(BaseSyncClientHandler.java:80) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.measureApiCallSuccess(BaseSyncClientHandler.java:182) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:74) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.core.client.handler.SdkSyncClientHandler.execute(SdkSyncClientHandler.java:45) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler.execute(AwsSyncClientHandler.java:53) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.services.sts.DefaultStsClient.assumeRole(DefaultStsClient.java:272) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.services.sts.auth.StsAssumeRoleCredentialsProvider.getUpdatedCredentials(StsAssumeRoleCredentialsProvider.java:73) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.services.sts.auth.StsCredentialsProvider.updateSessionCredentials(StsCredentialsProvider.java:92) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.utils.cache.CachedSupplier.lambda$jitteredPrefetchValueSupplier$8(CachedSupplier.java:300) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.utils.cache.CachedSupplier$PrefetchStrategy.fetch(CachedSupplier.java:448) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.utils.cache.CachedSupplier.refreshCache(CachedSupplier.java:208) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.utils.cache.CachedSupplier.get(CachedSupplier.java:135) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.services.sts.auth.StsCredentialsProvider.resolveCredentials(StsCredentialsProvider.java:105) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.services.sts.internal.StsProfileCredentialsProviderFactory$StsProfileCredentialsProvider.resolveCredentials(StsProfileCredentialsProviderFactory.java:109) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider.resolveCredentials(ProfileCredentialsProvider.java:131) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.auth.credentials.AwsCredentialsProvider.resolveIdentity(AwsCredentialsProvider.java:54) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.identity.spi.IdentityProvider.resolveIdentity(IdentityProvider.java:60) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.auth.credentials.AwsCredentialsProviderChain.resolveCredentials(AwsCredentialsProviderChain.java:103) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.auth.credentials.internal.LazyAwsCredentialsProvider.resolveCredentials(LazyAwsCredentialsProvider.java:45) ~[bundle-2.23.19.jar:?]
	at software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider.resolveCredentials(DefaultCredentialsProvider.java:128) ~[bundle-2.23.19.jar:?]
	at org.apache.hadoop.fs.s3a.AWSCredentialProviderList.resolveCredentials(AWSCredentialProviderList.java:175) ~[hadoop-aws-3.4.0.jar:?]
	at software.amazon.awssdk.auth.credentials.AwsCredentialsProvider.resolveIdentity(AwsCredentialsProvider.java:54) ~[bundle-2.23.19.jar:?]

What I'm doing:

We have to implement DefaultCredentialsProvider by ourselves, otherwise we may face "java.lang.IllegalStateException: Connection pool shut down" error.

Hadoop S3AFileSystem will call static AwsCredentialsProvider::create() to create CredentialsProvider.

But in DefaultCredentialsProvider::create(), it will only return a global static variable.

If we close S3AFileSystem, it will also close CredentialsProvider.

For the next time we create a new S3AFileSystem, it will reuse previous closed CredentialsProvider, then error will be thrown.

You can check the details in link: https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/troubleshooting.html#faq-connection-pool-shutdown-exception

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.3
    • 3.2
    • 3.1
    • 3.0
    • 2.5

@Smith-Cruise Smith-Cruise changed the title fix aws credentials [BugFix] Fix Connection pool shut down in S3AFilSystem Sep 10, 2024
@Smith-Cruise Smith-Cruise changed the title [BugFix] Fix Connection pool shut down in S3AFilSystem [BugFix] Fix "Connection pool shut down" in S3AFilSystem Sep 10, 2024
@Smith-Cruise Smith-Cruise changed the title [BugFix] Fix "Connection pool shut down" in S3AFilSystem [BugFix] Fix "Connection pool shut down" in S3AFileSystem Sep 10, 2024
@Smith-Cruise Smith-Cruise marked this pull request as ready for review September 10, 2024 06:34
@Smith-Cruise Smith-Cruise requested a review from a team as a code owner September 10, 2024 06:34
kevincai
kevincai previously approved these changes Sep 23, 2024
Signed-off-by: Smith Cruise <[email protected]>
Signed-off-by: Smith Cruise <[email protected]>
Signed-off-by: Smith Cruise <[email protected]>
Signed-off-by: Smith Cruise <[email protected]>
Signed-off-by: Smith Cruise <[email protected]>
Signed-off-by: Smith Cruise <[email protected]>
Signed-off-by: Smith Cruise <[email protected]>
Signed-off-by: Smith Cruise <[email protected]>
Copy link

sonarcloud bot commented Sep 24, 2024

Copy link

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

[FE Incremental Coverage Report]

pass : 222 / 267 (83.15%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/connector/hive/glue/metastore/AWSGlueClientFactory.java 0 1 00.00% [43]
🔵 com/starrocks/credential/aws/AwsCloudCredential.java 117 154 75.97% [160, 162, 171, 174, 178, 179, 180, 181, 182, 185, 186, 187, 188, 196, 198, 201, 202, 207, 209, 241, 242, 244, 253, 254, 260, 349, 357, 358, 360, 362, 363, 364, 365, 366, 367, 370, 371]
🔵 com/starrocks/credential/aws/AwsCloudConfigurationProvider.java 36 39 92.31% [96, 97, 101]
🔵 com/starrocks/credential/aws/AwsCloudConfiguration.java 60 64 93.75% [48, 49, 56, 57]
🔵 com/starrocks/connector/paimon/PaimonConnector.java 2 2 100.00% []
🔵 com/starrocks/credential/CloudConfigurationFactory.java 2 2 100.00% []
🔵 com/starrocks/credential/provider/OverwriteAwsDefaultCredentialsProvider.java 5 5 100.00% []

Copy link

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

@dirtysalt dirtysalt merged commit 9222444 into StarRocks:main Sep 24, 2024
46 of 47 checks passed
Copy link

@Mergifyio backport branch-3.3

Copy link

@Mergifyio backport branch-3.2

Copy link
Contributor

mergify bot commented Sep 24, 2024

backport branch-3.3

✅ Backports have been created

Copy link
Contributor

mergify bot commented Sep 24, 2024

backport branch-3.2

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Sep 24, 2024
mergify bot pushed a commit that referenced this pull request Sep 24, 2024
Signed-off-by: Smith Cruise <[email protected]>
(cherry picked from commit 9222444)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/credential/aws/AwsCloudConfigurationProvider.java
#	fe/fe-core/src/test/java/com/starrocks/credential/CloudConfigurationFactoryTest.java
#	fe/fe-core/src/test/java/com/starrocks/server/SharedDataStorageVolumeMgrTest.java
dirtysalt pushed a commit that referenced this pull request Sep 24, 2024
renzhimin7 pushed a commit to renzhimin7/starrocks that referenced this pull request Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants