Treat transaction conflicts during transactional account updates as contested optimistic locks

This commit is contained in:
Jon Chambers authored and Jon Chambers committed 2023-12-08 12:13:23 -05:00
1 parent 417d99a17e
commit cca747a1f6
2 files changed
+35 -1

No files matched your search

@@ -887,7 +887,14 @@ public class Accounts extends AbstractDynamoDbStore {
final Throwable unwrapped = ExceptionUtils.unwrap(throwable);
if (unwrapped instanceof TransactionCanceledException transactionCanceledException) {
if ("ConditionalCheckFailed".equals(transactionCanceledException.cancellationReasons().get(0).code())) {
if (CONDITIONAL_CHECK_FAILED.equals(transactionCanceledException.cancellationReasons().get(0).code())) {
throw new ContestedOptimisticLockException();
}
if (transactionCanceledException.cancellationReasons()
.stream()
.anyMatch(reason -> TRANSACTION_CONFLICT.equals(reason.code()))) {
throw new ContestedOptimisticLockException();
}
}