aws-sdk-java icon indicating copy to clipboard operation
aws-sdk-java copied to clipboard

@DynamoDBIndexRangeKey Silently Disables @DynamoDBVersionAttribute

Open BitFracture opened this issue 6 years ago • 3 comments

I have defined a POJO/DTO with a secondary index range key which is also used as the version attribute for optimistic locking. The result is that there is no locking enforcement, but the version value still gets incremented during write. No exceptions are thrown and this fails silently.

Example partial DTO (uses Lombok, may or may not be related):

@Data
@NoArgsConstructor
public class MyDto {
    ...
    @DynamoDBIndexRangeKey(globalSecondaryIndexName = INDEX_CANONICAL)
    @DynamoDBVersionAttribute
    private Long resourceVersion;
    ...
}

The expected behavior is that locking should be enforced or an exception should be thrown to warn that this pair of annotations/behavior is not currently supported.

  • Mac OS 10.14.2
  • OpenJDK version "11.0.1" 2018-10-16
  • OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
  • AWS SDK Java 1.11.492

For those curious about the function of a key also being a version attribute: the locking is only used for the most recent version of the resource, and historical (canonical) resources go around locking using clobber. With both historical and most recent resources in this canonical index, one may fetch any canonical resource by ID and version number.

BitFracture avatar Feb 07 '19 00:02 BitFracture

Hi @BitFracture, I was able to reproduce your case. I will show my findings to the team and will discuss the best behavior for this particular case.

debora-ito avatar Feb 09 '19 03:02 debora-ito

Hi @debora-ito, thanks for looking at this. What's the typical turnaround on issues like this? I would like to inform my team know how long we will have a workaround in place. Thanks!

erikgreif-acc avatar Mar 07 '19 01:03 erikgreif-acc

@erikgreif-acc we don't have a timeline for when it will be available, unfortunately

debora-ito avatar Mar 12 '19 21:03 debora-ito

This won't get fixed in v1 before going into Maintenance Mode. Closing.

If the issue still persists in v2 DynamoDB Enhanced Client, please open a new issue in the v2 repo.

Reference:

  • Announcing end-of-support for AWS SDK for Java v1.x effective December 31, 2025 - blog post

debora-ito avatar Jul 26 '24 22:07 debora-ito

This issue is now closed.

Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.

github-actions[bot] avatar Jul 26 '24 22:07 github-actions[bot]