Add account to migration retry table on transient dynamo failure
This commit is contained in:
parent
b91a69d8b3
commit
f3b9a8d97f
|
@ -215,18 +215,25 @@ public class AccountsDynamoDb extends AbstractDynamoDbStore implements AccountSt
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
UpdateItemResponse response = client.updateItem(updateItemRequest);
|
try {
|
||||||
|
UpdateItemResponse response = client.updateItem(updateItemRequest);
|
||||||
|
|
||||||
account.setVersion(AttributeValues.getInt(response.attributes(), "V", account.getVersion() + 1));
|
account.setVersion(AttributeValues.getInt(response.attributes(), "V", account.getVersion() + 1));
|
||||||
} catch (final TransactionConflictException e) {
|
} catch (final TransactionConflictException e) {
|
||||||
|
|
||||||
throw new ContestedOptimisticLockException();
|
throw new ContestedOptimisticLockException();
|
||||||
|
|
||||||
} catch (final ConditionalCheckFailedException e) {
|
} catch (final ConditionalCheckFailedException e) {
|
||||||
|
|
||||||
// the exception doesn’t give details about which condition failed,
|
// the exception doesn’t give details about which condition failed,
|
||||||
// but we can infer it was an optimistic locking failure if the UUID is known
|
// but we can infer it was an optimistic locking failure if the UUID is known
|
||||||
throw get(account.getUuid()).isPresent() ? new ContestedOptimisticLockException() : e;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue