tkalkirill commented on code in PR #4663: URL: https://github.com/apache/ignite-3/pull/4663#discussion_r1827600545
########## modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageManagerImpl.java: ########## @@ -311,75 +316,37 @@ public void addElectionListener(ElectionListener listener) { electionListeners.add(listener); } - private CompletableFuture<Long> recover(MetaStorageService service) { - if (!busyLock.enterBusy()) { - return failedFuture(new NodeStoppingException()); - } + private CompletableFuture<?> updateTargetRevisionsForRecovery(MetaStorageService service) { + return inBusyLockAsync(busyLock, () -> { + service.currentRevisions() + .thenAccept(targetRevisions -> { + assert targetRevisions != null; - try { - service.currentRevision().whenComplete((targetRevision, throwable) -> { - if (throwable != null) { - recoveryFinishedFuture.completeExceptionally(throwable); + LOG.info("Performing MetaStorage recovery: [from={}, to={}]", storage.revisions(), targetRevisions); - return; - } + recoveryRevisionsListener.setTargetRevisions(targetRevisions.toRevisions()); + }).whenComplete((res, throwable) -> { + if (throwable != null) { + recoveryFinishedFuture.completeExceptionally(throwable); + } + }); - LOG.info("Performing MetaStorage recovery from revision {} to {}", storage.revision(), targetRevision); + return recoveryFinishedFuture.whenComplete((revisions, throwable) -> { + if (throwable != null) { + LOG.info("Recovery failed", throwable); + } else { + long recoveryRevision = revisions.revision(); - assert targetRevision != null; + appliedRevision = recoveryRevision; - listenForRecovery(targetRevision); - }).whenComplete((res, ex) -> { - if (ex != null) { - LOG.info("Recovery failed", ex); + if (recoveryRevision > 0) { + clusterTime.updateSafeTime(storage.timestampByRevision(recoveryRevision)); + } - recoveryFinishedFuture.completeExceptionally(ex); + LOG.info("Finished MetaStorage recovery"); Review Comment: Fix it a little differently. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org