Treat transaction conflicts during transactional account updates as contested optimistic locks

This commit is contained in:
Jon Chambers
2023-12-07 22:42:25 -05:00
committed by Jon Chambers
parent 417d99a17e
commit cca747a1f6
2 changed files with 35 additions and 1 deletions

View File

@@ -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();
}
}