derjust / spring-data-dynamodb

This module deals with enhanced support for a data access layer built on AWS DynamoDB.
https://derjust.github.io/spring-data-dynamodb/
Apache License 2.0
403 stars 141 forks source link

findById method invocation hangs, never return control #201

Open ghost opened 6 years ago

ghost commented 6 years ago

Expected Behavior

findById method should return control

Actual Behavior

findById method never return control and simply hangs

Steps to Reproduce the Problem

  1. Create a Spring project that has the DynamoDB Configurations and also has the repository classes
  2. Create a separate project for Kinesis Client library

Code

        <!-- https://mvnrepository.com/artifact/com.amazonaws/amazon-kinesis-client -->
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>amazon-kinesis-client</artifactId>
            <version>1.9.2</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
  1. Create a spring boot project that references the above 2 projects in its pom.xml. Provide implementation for IRecordProcessor in this project and start the project. Submit event through a stream. This project will consume the event and process the data. As part of data processing call the repository classes findById method. It simply hangs.

    @Id
    @DynamoDBHashKey
    private String key;

    Specifications

    • Spring Data DynamoDB Version: 5.0.2 (2.0)
    • Spring Data Version: 2.0.10.RELEASE
    • AWS SDK Version: 1.11.306
    • Java Version: 1.8.0_102 - Java HotSpot(TM) 64-Bit Server VM 25.102-b14
    • Platform Details: AWS ECS and Mac OS X 10.13.6
      --- maven-dependency-plugin:3.0.2:tree (default-cli) @ request-processor ---
      [INFO] com.myteam.project:request-processor:jar:1.0.0-SNAPSHOT
      [INFO] +- com.myteam.project:common-component:jar:1.0.0-SNAPSHOT:compile
      [INFO] |  +- com.github.spullara.mustache.java:compiler:jar:0.9.2:compile
      [INFO] |  +- org.apache.commons:commons-lang3:jar:3.7:compile
      [INFO] |  +- org.springframework.retry:spring-retry:jar:1.2.2.RELEASE:compile
      [INFO] |  +- org.slf4j:log4j-over-slf4j:jar:1.7.25:compile
      [INFO] |  |  \- org.slf4j:slf4j-api:jar:1.7.25:compile
      [INFO] |  +- com.amazonaws:aws-java-sdk-ses:jar:1.11.306:compile
      [INFO] |  +- com.amazonaws:aws-java-sdk-sts:jar:1.11.306:compile
      [INFO] |  +- com.amazonaws:aws-java-sdk-dynamodb:jar:1.11.306:compile
      [INFO] |  |  \- com.amazonaws:aws-java-sdk-s3:jar:1.11.306:compile
      [INFO] |  +- com.amazonaws:aws-java-sdk-kms:jar:1.11.306:compile
      [INFO] |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.6:compile
      [INFO] |  +- com.github.spring-data-dynamodb:spring-data-dynamodb:jar:5.0.2:compile
      [INFO] |  |  +- org.springframework:spring-context:jar:5.0.9.RELEASE:compile
      [INFO] |  |  +- org.springframework:spring-tx:jar:5.0.9.RELEASE:compile
      [INFO] |  |  +- org.springframework.data:spring-data-commons:jar:2.0.10.RELEASE:compile
      [INFO] |  |  +- org.hibernate:hibernate-validator:jar:5.2.4.Final:compile
      [INFO] |  |  \- javax.enterprise:cdi-api:jar:1.2:compile
      [INFO] |  |     +- javax.el:javax.el-api:jar:3.0.0:compile
      [INFO] |  |     +- javax.interceptor:javax.interceptor-api:jar:1.2:compile
      [INFO] |  |     \- javax.inject:javax.inject:jar:1:compile
      [INFO] |  +- io.springfox:springfox-swagger2:jar:2.4.0:compile
      [INFO] |  |  +- io.swagger:swagger-annotations:jar:1.5.6:compile
      [INFO] |  |  +- io.swagger:swagger-models:jar:1.5.6:compile
      [INFO] |  |  +- io.springfox:springfox-spi:jar:2.4.0:compile
      [INFO] |  |  |  \- io.springfox:springfox-core:jar:2.4.0:compile
      [INFO] |  |  +- io.springfox:springfox-schema:jar:2.4.0:compile
      [INFO] |  |  +- io.springfox:springfox-swagger-common:jar:2.4.0:compile
      [INFO] |  |  +- io.springfox:springfox-spring-web:jar:2.4.0:compile
      [INFO] |  |  +- com.fasterxml:classmate:jar:1.3.4:compile
      [INFO] |  |  +- org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile
      [INFO] |  |  \- org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile
      [INFO] |  \- org.springframework.security:spring-security-crypto:jar:5.0.8.RELEASE:compile
      [INFO] +- com.myteam.components:kinesis-client-library-component:jar:1.0.0-SNAPSHOT:compile
      [INFO] |  +- commons-logging:commons-logging:jar:1.2:compile
      [INFO] |  \- com.amazonaws:amazon-kinesis-client:jar:1.9.2:compile
      [INFO] |     +- com.amazonaws:aws-java-sdk-cloudwatch:jar:1.11.306:compile
      [INFO] |     +- com.google.protobuf:protobuf-java:jar:2.6.1:compile
      [INFO] |     \- commons-lang:commons-lang:jar:2.6:compile
      [INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.0.5.RELEASE:compile
      [INFO] |  +- org.springframework.boot:spring-boot-starter:jar:2.0.5.RELEASE:compile
      [INFO] |  |  +- org.springframework.boot:spring-boot:jar:2.0.5.RELEASE:compile
      [INFO] |  |  +- org.springframework.boot:spring-boot-autoconfigure:jar:2.0.5.RELEASE:compile
      [INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.0.5.RELEASE:compile
      [INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.2.3:compile
      [INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.2.3:compile
      [INFO] |  |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
      [INFO] |  |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
      [INFO] |  |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
      [INFO] |  |  +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
      [INFO] |  |  \- org.yaml:snakeyaml:jar:1.19:runtime
      [INFO] |  +- org.springframework.boot:spring-boot-starter-json:jar:2.0.5.RELEASE:compile
      [INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.6:compile
      [INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.6:compile
      [INFO] |  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.6:compile
      [INFO] |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.0.5.RELEASE:compile
      [INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.34:compile
      [INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.34:compile
      [INFO] |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.34:compile
      [INFO] |  +- org.hibernate.validator:hibernate-validator:jar:6.0.12.Final:compile
      [INFO] |  |  +- javax.validation:validation-api:jar:2.0.1.Final:compile
      [INFO] |  |  \- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
      [INFO] |  +- org.springframework:spring-web:jar:5.0.9.RELEASE:compile
      [INFO] |  |  \- org.springframework:spring-beans:jar:5.0.9.RELEASE:compile
      [INFO] |  \- org.springframework:spring-webmvc:jar:5.0.9.RELEASE:compile
      [INFO] |     \- org.springframework:spring-expression:jar:5.0.9.RELEASE:compile
      [INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:2.0.5.RELEASE:compile
      [INFO] |  +- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:2.0.5.RELEASE:compile
      [INFO] |  |  \- org.springframework.boot:spring-boot-actuator:jar:2.0.5.RELEASE:compile
      [INFO] |  \- io.micrometer:micrometer-core:jar:1.0.6:compile
      [INFO] |     +- org.hdrhistogram:HdrHistogram:jar:2.1.10:compile
      [INFO] |     \- org.latencyutils:LatencyUtils:jar:2.0.3:compile
      [INFO] +- org.springframework.boot:spring-boot-starter-aop:jar:2.0.5.RELEASE:compile
      [INFO] |  +- org.springframework:spring-aop:jar:5.0.9.RELEASE:compile
      [INFO] |  \- org.aspectj:aspectjweaver:jar:1.8.13:compile
      [INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.0.5.RELEASE:test
      [INFO] |  +- org.springframework.boot:spring-boot-test:jar:2.0.5.RELEASE:test
      [INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.0.5.RELEASE:test
      [INFO] |  +- com.jayway.jsonpath:json-path:jar:2.4.0:test
      [INFO] |  |  \- net.minidev:json-smart:jar:2.3:test
      [INFO] |  |     \- net.minidev:accessors-smart:jar:1.2:test
      [INFO] |  |        \- org.ow2.asm:asm:jar:5.0.4:test
      [INFO] |  +- junit:junit:jar:4.12:test
      [INFO] |  +- org.assertj:assertj-core:jar:3.9.1:test
      [INFO] |  +- org.hamcrest:hamcrest-core:jar:1.3:test
      [INFO] |  +- org.hamcrest:hamcrest-library:jar:1.3:test
      [INFO] |  +- org.skyscreamer:jsonassert:jar:1.5.0:test
      [INFO] |  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
      [INFO] |  +- org.springframework:spring-core:jar:5.0.9.RELEASE:compile
      [INFO] |  |  \- org.springframework:spring-jcl:jar:5.0.9.RELEASE:compile
      [INFO] |  +- org.springframework:spring-test:jar:5.0.9.RELEASE:test
      [INFO] |  \- org.xmlunit:xmlunit-core:jar:2.5.1:test
      [INFO] +- com.amazonaws:aws-java-sdk-kinesis:jar:1.11.306:compile
      [INFO] |  +- com.amazonaws:aws-java-sdk-core:jar:1.11.306:compile
      [INFO] |  |  +- software.amazon.ion:ion-java:jar:1.0.2:compile
      [INFO] |  |  \- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.9.6:compile
      [INFO] |  \- com.amazonaws:jmespath-java:jar:1.11.306:compile
      [INFO] +- com.twilio.sdk:twilio:jar:7.17.0:compile
      [INFO] |  +- com.google.guava:guava:jar:18.0:compile
      [INFO] |  +- joda-time:joda-time:jar:2.9.9:compile
      [INFO] |  +- io.jsonwebtoken:jjwt:jar:0.4:compile
      [INFO] |  +- org.apache.httpcomponents:httpclient:jar:4.5.6:compile
      [INFO] |  |  \- commons-codec:commons-codec:jar:1.11:compile
      [INFO] |  +- org.apache.httpcomponents:httpcore:jar:4.4.10:compile
      [INFO] |  +- com.fasterxml.jackson.core:jackson-core:jar:2.9.6:compile
      [INFO] |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
      [INFO] |  \- javax.xml.bind:jaxb-api:jar:2.3.0:compile
      [INFO] +- org.mockito:mockito-all:jar:1.10.19:test
      [INFO] \- org.mockito:mockito-core:jar:2.21.0:test
      [INFO]    +- net.bytebuddy:byte-buddy:jar:1.7.11:test
      [INFO]    +- net.bytebuddy:byte-buddy-agent:jar:1.7.11:test
      [INFO]    \- org.objenesis:objenesis:jar:2.6:test
ghost commented 6 years ago

What I observed is, AfterLoad event is successfully created, fetching values from DynamoDB. The issue seems to be with a synchronization lock. The SimpleApplicationEventMulticaster.multicastEvent method tries to load getApplicationListeners(). In AbstractApplicationEventMulticaster, getApplicationListeners method, the synchronized block, "synchronized(this.retrievalMutex)" goes to wait state indefinitely. Not sure why it happens. Not sure if this is an issue, if we use Spring data within Amazon Kinesis Client library . Any suggestion to move forward will be really helpful.

ghost commented 6 years ago

My issue is the same issue as that of https://github.com/derjust/spring-data-dynamodb/issues/170. Please review this. I am not sure why there is no exception or anything, simply the execution stops.

derjust commented 6 years ago

Can you please check if the solution for #170 applies to you, too? Is your Kinesis on the main thread? Or can you share what you are doing with KCL?

Thanks