} catch (OptimisticLockException | OptimisticLockingFailureException e) {
LOGGER.info("Failed to update stack status. [attempt: '{}', Cause: {}]. Trying to save it again.", attempt++, e.getClass().getSimpleName());
if (attempt <= MAX_RETRIES) {
return doUpdateStackStatus(stackId, status, statusReason);
} else {
throw new InternalServerException(String.format("Failed to update stack '%s' in 5 attempts. (while trying to update status)", stackId), e);
}
}
}