Source:
<code>void markContainerInactiveOnZk(Set<Container> inactiveContainerCandidateSet) { if (inactiveContainerCandidateSet != null) { Map<Short, Account> accountToUpdateMap = new HashMap<>(); inactiveContainerCandidateSet.forEach(container -> { container = new ContainerBuilder(container).setStatus(Container.ContainerStatus.INACTIVE).build(); short accountId = container.getParentAccountId(); Account account = new AccountBuilder(accountToUpdateMap.getOrDefault(accountId, getAccountById(accountId))).addOrUpdateContainer(container).build(); accountToUpdateMap.put(accountId, account); }); <START> updateAccounts(accountToUpdateMap.values()); <END> } }</code><technical_language>some situations this update fail persist if is making other account updates in Nuage concurrently. This is update fail if account's "snapshotVersion" field match. This field is base account modified matches current account stored in zookeeper update erase else's change unexpectedly. I suggest a compareAndSet style loop (checking return of updateAccounts if update through): java if (inactiveContainerCandidateSet != null) { boolean successful = false; while (!successful) { Map<Short, Account> accountToUpdateMap = new HashMap<>(); inactiveContainerCandidateSet.forEach(container -> { // start account, get container account editing // snapshot short accountId = container.getParentAccountId(); Account accountToEdit = accountToUpdateMap.computeIfAbsent(accountId, this::getAccountById); Container containerToEdit = accountToEdit.getContainerById(container.getId()); Container editedContainer = new ContainerBuilder(containerToEdit).setStatus(Container.ContainerStatus.INACTIVE).build(); accountToUpdateMap.put(accountId, new AccountBuilder(accountToEdit).addOrUpdateContainer(editedContainer).build()); }); // Note this assumes unsuccessful updates retriable (like snapshot version violations). // If is unrecoverable wrong, this method get stuck in this loop. // Limit number of retries needed. successful = updateAccounts(accountToUpdateMap.values()); } }</technical_language>

Target:
void markContainerInactiveOnZk(Set<Container> inactiveContainerCandidateSet) throws InterruptedException { if (inactiveContainerCandidateSet != null) { boolean success = false; int retry = 0; while (!success && retry < config.maxRetryCountOnUpdateFailure) { Map<Short, Account> accountToUpdateMap = new HashMap<>(); inactiveContainerCandidateSet.forEach(container -> { short accountId = container.getParentAccountId(); Account accountToEdit = accountToUpdateMap.computeIfAbsent(accountId, this::getAccountById); Container containerToEdit = accountToEdit.getContainerById(container.getId()); Container editedContainer = new ContainerBuilder(containerToEdit).setStatus(Container.ContainerStatus.INACTIVE).build(); accountToUpdateMap.put(accountId, new AccountBuilder(accountToEdit).addOrUpdateContainer(editedContainer).build()); }); success = updateAccounts(accountToUpdateMap.values()); if (!success) { retry++; Thread.sleep(config.retryDelayMs); } } if (!success) { logger.error("Failed to mark containers INACTIVE in set : after retries", inactiveContainerCandidateSet, config.maxRetryCountOnUpdateFailure); accountServiceMetrics.accountUpdatesToZkErrorCount.inc(); } } }