GithubHelp home page GithubHelp logo

Comments (2)

artembilan avatar artembilan commented on June 2, 2024

Thank you for sharing this with us!
Unfortunately I cannot start your application:

  1. Even if you marked it with a @Primary in the LocalStackConfiguration, the other bean is still created and it fails with this error:
Caused by: com.amazonaws.SdkClientException: Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region.
	at com.amazonaws.client.builder.AwsClientBuilder.setRegion(AwsClientBuilder.java:462) ~[aws-java-sdk-core-1.12.266.jar:na]
	at com.amazonaws.client.builder.AwsClientBuilder.configureMutableProperties(AwsClientBuilder.java:424) ~[aws-java-sdk-core-1.12.266.jar:na]
	at com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:46) ~[aws-java-sdk-core-1.12.266.jar:na]
	at com.example.lockbug.DynamoDbLockBugConfiguration.amazonDynamoDB(DynamoDbLockBugConfiguration.java:40) ~[main/:na]
  1. When I remove that bean in the DynamoDbLockBugConfiguration, I fail with this error:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'amazonS3': Invocation of init method failed; nested exception is com.amazonaws.SdkClientException: Unable to load region information from any provider in the chain
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.24.jar:5.3.24]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.24.jar:5.3.24]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.24.jar:5.3.24]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.24.jar:5.3.24]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.24.jar:5.3.24]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.24.jar:5.3.24]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.24.jar:5.3.24]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:936) ~[spring-beans-5.3.24.jar:5.3.24]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.24.jar:5.3.24]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.24.jar:5.3.24]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731) ~[spring-boot-2.7.7.jar:2.7.7]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.7.jar:2.7.7]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) ~[spring-boot-2.7.7.jar:2.7.7]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) ~[spring-boot-2.7.7.jar:2.7.7]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) ~[spring-boot-2.7.7.jar:2.7.7]
	at com.example.lockbug.LockBugApplication.main(LockBugApplication.java:10) ~[main/:na]
Caused by: com.amazonaws.SdkClientException: Unable to load region information from any provider in the chain
	at com.amazonaws.regions.AwsRegionProviderChain.getRegion(AwsRegionProviderChain.java:59) ~[aws-java-sdk-core-1.12.266.jar:na]
	at io.awspring.cloud.core.region.DefaultAwsRegionProviderChainDelegate.getRegion(DefaultAwsRegionProviderChainDelegate.java:37) ~[spring-cloud-aws-core-2.4.2.jar:2.4.2]
	at io.awspring.cloud.core.config.AmazonWebserviceClientFactoryBean.createInstance(AmazonWebserviceClientFactoryBean.java:130) ~[spring-cloud-aws-core-2.4.2.jar:2.4.2]
	at io.awspring.cloud.core.config.AmazonWebserviceClientFactoryBean.createInstance(AmazonWebserviceClientFactoryBean.java:52) ~[spring-cloud-aws-core-2.4.2.jar:2.4.2]
	at org.springframework.beans.factory.config.AbstractFactoryBean.afterPropertiesSet(AbstractFactoryBean.java:142) ~[spring-beans-5.3.24.jar:5.3.24]

Apparently some other AWS services are trying to be auto-configured and you probably have some AWS SDK configuration locally in the ~/.aws/credentials.

Anyway I have a code from you so I'll try to reproduce it and play with from JUnit test where I use Testcontainers for LocalStack instead.

Will come back with some finding a bit later...

from spring-integration-aws.

artembilan avatar artembilan commented on June 2, 2024

OK. So, I see (or at least guess) what is going on.
This logic in the AmazonDynamoDBLockClient has no sense:

if (options.shouldSkipBlockingWait() && existingLock.isPresent() && !existingLock.get().isExpired()) {

That isExpired() is always true:

return LockClientUtils.INSTANCE.millisecondTime() - this.lookupTime.get() > this.leaseDuration.get();

where that this.lookupTime is set exactly as a LockClientUtils.INSTANCE.millisecondTime() in the getLockFromDynamoDB(getLockOptions) method call from the beginning of the while (true) loop in the acquireLock().
So, no matter how much we try to wait in between lock.tryLock(), that isExpired() is always false when we do shouldSkipBlockingWait().

I will try to find some workaround (at least restore the previous behavior), but it feel like a bug in the DynamoDB Lock Client library by itself.
There is no reasonable lookupTime to make an item to expire in time for our call when we don't want to wait.
And therefore we end up with an impression that it never expires. 🤷

from spring-integration-aws.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.