From fb39af67e5e5433f10aed2a7cbe9aee491b19789 Mon Sep 17 00:00:00 2001 From: Chris Eager Date: Wed, 31 Jan 2024 17:31:23 -0600 Subject: [PATCH] Allow for more TransactWriteItems when inspecting TransactionCanceledException --- .../org/whispersystems/textsecuregcm/storage/Accounts.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/storage/Accounts.java b/service/src/main/java/org/whispersystems/textsecuregcm/storage/Accounts.java index 2fbe8c46f..a26c43490 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/Accounts.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/Accounts.java @@ -430,7 +430,7 @@ public class Accounts extends AbstractDynamoDbStore { } catch (final JsonProcessingException e) { throw new IllegalArgumentException(e); } catch (final TransactionCanceledException e) { - if (e.hasCancellationReasons() && e.cancellationReasons().size() == 6) { + if (e.hasCancellationReasons() && e.cancellationReasons().size() == 6 + additionalWriteItems.size()) { // the cancellation reasons map to the write items: // 0. phone number constraint delete - no conditions // 1. phone number constraint put - conditional on the key not existing (it is deleted by 0) @@ -438,6 +438,8 @@ public class Accounts extends AbstractDynamoDbStore { // 3. pni constraint put - conditional on the key not existing (it is deleted by 2) // 4. deleted accounts delete - no conditions // 5. account update - conditional on #version = :version + // 6. additional write items… + // 7. additional write items… if (CONDITIONAL_CHECK_FAILED.equals(e.cancellationReasons().get(5).code())) { // the #version = :version condition failed, which indicates a concurrent update throw new ContestedOptimisticLockException();