@DynamoDBIndexRangeKey Silently Disables @DynamoDBVersionAttribute
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.
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.
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 we don't have a timeline for when it will be available, unfortunately
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
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.