Add account to migration retry table on transient dynamo failure

This commit is contained in:
Chris Eager
2021-09-03 14:15:22 -07:00
committed by Chris Eager
parent b91a69d8b3
commit f3b9a8d97f

View File

@@ -215,18 +215,25 @@ public class AccountsDynamoDb extends AbstractDynamoDbStore implements AccountSt
}
try {
UpdateItemResponse response = client.updateItem(updateItemRequest);
try {
UpdateItemResponse response = client.updateItem(updateItemRequest);
account.setVersion(AttributeValues.getInt(response.attributes(), "V", account.getVersion() + 1));
} catch (final TransactionConflictException e) {
account.setVersion(AttributeValues.getInt(response.attributes(), "V", account.getVersion() + 1));
} catch (final TransactionConflictException e) {
throw new ContestedOptimisticLockException();
throw new ContestedOptimisticLockException();
} catch (final ConditionalCheckFailedException e) {
} catch (final ConditionalCheckFailedException e) {
// the exception doesnt give details about which condition failed,
// but we can infer it was an optimistic locking failure if the UUID is known
throw get(account.getUuid()).isPresent() ? new ContestedOptimisticLockException() : e;
// the exception doesnt give details about which condition failed,
// but we can infer it was an optimistic locking failure if the UUID is known
throw get(account.getUuid()).isPresent() ? new ContestedOptimisticLockException() : e;
}
} catch (final Exception e) {
// the Dynamo account now lags the Postgres account version. Put it in the migration retry table so that it will
// get updated faster—otherwise it will be stale until the accounts crawler runs again
migrationRetryAccounts.put(account.getUuid());
throw e;
}
});