You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by na...@apache.org on 2021/08/25 04:49:11 UTC

[ignite] branch master updated: IGNITE-14070 Implement API for custom snapshot lifecycle handlers. (#9165)

This is an automated email from the ASF dual-hosted git repository.

namelchev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new 9856562  IGNITE-14070 Implement API for custom snapshot lifecycle handlers. (#9165)
9856562 is described below

commit 98565628bfe573998b72b6382d6af5bf063257c2
Author: Pavel Pereslegin <xx...@gmail.com>
AuthorDate: Wed Aug 25 07:47:55 2021 +0300

    IGNITE-14070 Implement API for custom snapshot lifecycle handlers. (#9165)
---
 .../snapshot/AbstractSnapshotVerificationTask.java | 116 +++++++
 .../snapshot/IgniteSnapshotManager.java            | 289 +++++++++++++++--
 .../persistence/snapshot/SnapshotHandler.java      |  78 +++++
 .../snapshot/SnapshotHandlerContext.java           |  69 ++++
 .../snapshot/SnapshotHandlerRestoreTask.java       | 139 ++++++++
 .../snapshot/SnapshotHandlerResult.java            |  68 ++++
 .../persistence/snapshot/SnapshotHandlerType.java  |  29 ++
 .../snapshot/SnapshotOperationRequest.java         |  18 ++
 .../snapshot/SnapshotPartitionsVerifyHandler.java  | 252 +++++++++++++++
 .../snapshot/SnapshotPartitionsVerifyTask.java     | 241 +-------------
 .../snapshot/SnapshotRestoreProcess.java           |  15 +-
 .../snapshot/IgniteClusterSnapshotCheckTest.java   |   2 +-
 .../snapshot/IgniteClusterSnapshotHandlerTest.java | 351 +++++++++++++++++++++
 .../IgniteClusterSnapshotRestoreBaseTest.java      |  43 +++
 .../IgniteClusterSnapshotRestoreSelfTest.java      |  60 ++--
 .../snapshot/IgniteClusterSnapshotSelfTest.java    |   9 +-
 .../IgniteBasicWithPersistenceTestSuite.java       |   2 +
 17 files changed, 1468 insertions(+), 313 deletions(-)

diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/AbstractSnapshotVerificationTask.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/AbstractSnapshotVerificationTask.java
new file mode 100644
index 0000000..1f2a48a
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/AbstractSnapshotVerificationTask.java
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.persistence.snapshot;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeJobResultPolicy;
+import org.apache.ignite.compute.ComputeTaskAdapter;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.resources.IgniteInstanceResource;
+
+/**
+ * The task for checking the consistency of snapshots in the cluster.
+ */
+public abstract class AbstractSnapshotVerificationTask extends
+    ComputeTaskAdapter<SnapshotPartitionsVerifyTaskArg, SnapshotPartitionsVerifyTaskResult> {
+    /** Serial version uid. */
+    private static final long serialVersionUID = 0L;
+
+    /** Map of snapshot metadata information found on each cluster node. */
+    protected final Map<ClusterNode, List<SnapshotMetadata>> metas = new HashMap<>();
+
+    /** Ignite instance. */
+    @IgniteInstanceResource
+    protected IgniteEx ignite;
+
+    /** {@inheritDoc} */
+    @Override public Map<ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, SnapshotPartitionsVerifyTaskArg arg) {
+        Map<ClusterNode, List<SnapshotMetadata>> clusterMetas = arg.clusterMetadata();
+
+        if (!subgrid.containsAll(clusterMetas.keySet())) {
+            throw new IgniteSnapshotVerifyException(F.asMap(ignite.localNode(),
+                new IgniteException("Some of Ignite nodes left the cluster during the snapshot verification " +
+                    "[curr=" + F.viewReadOnly(subgrid, F.node2id()) +
+                    ", init=" + F.viewReadOnly(clusterMetas.keySet(), F.node2id()) + ']')));
+        }
+
+        Map<ComputeJob, ClusterNode> jobs = new HashMap<>();
+        Set<SnapshotMetadata> allMetas = new HashSet<>();
+        clusterMetas.values().forEach(allMetas::addAll);
+
+        Set<String> missed = null;
+
+        for (SnapshotMetadata meta : allMetas) {
+            if (missed == null)
+                missed = new HashSet<>(meta.baselineNodes());
+
+            missed.remove(meta.consistentId());
+
+            if (missed.isEmpty())
+                break;
+        }
+
+        if (!missed.isEmpty()) {
+            throw new IgniteSnapshotVerifyException(F.asMap(ignite.localNode(),
+                new IgniteException("Some metadata is missing from the snapshot: " + missed)));
+        }
+
+        metas.putAll(clusterMetas);
+
+        while (!allMetas.isEmpty()) {
+            for (Map.Entry<ClusterNode, List<SnapshotMetadata>> e : clusterMetas.entrySet()) {
+                SnapshotMetadata meta = F.find(e.getValue(), null, allMetas::remove);
+
+                if (meta == null)
+                    continue;
+
+                jobs.put(createJob(meta.snapshotName(), meta.consistentId(), arg.cacheGroupNames()),
+                    e.getKey());
+
+                if (allMetas.isEmpty())
+                    break;
+            }
+        }
+
+        return jobs;
+    }
+
+    /** {@inheritDoc} */
+    @Override public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult> rcvd) throws IgniteException {
+        // Handle all exceptions during the `reduce` operation.
+        return ComputeJobResultPolicy.WAIT;
+    }
+
+    /**
+     * @param name Snapshot name.
+     * @param constId Snapshot metadata file name.
+     * @param groups Cache groups to be restored from the snapshot. May be empty if all cache groups are being restored.
+     * @return Compute job.
+     */
+    protected abstract ComputeJob createJob(String name, String constId, Collection<String> groups);
+}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
index 45ec8d2..fb6086d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
@@ -42,6 +42,7 @@ import java.util.BitSet;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Deque;
+import java.util.EnumMap;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedList;
@@ -55,6 +56,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.RejectedExecutionException;
 import java.util.function.BiFunction;
 import java.util.function.Function;
 import java.util.function.Predicate;
@@ -127,6 +129,7 @@ import org.apache.ignite.internal.util.lang.GridPlainRunnable;
 import org.apache.ignite.internal.util.lang.IgniteThrowableFunction;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.T2;
 import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.S;
@@ -310,6 +313,9 @@ public class IgniteSnapshotManager extends GridCacheSharedManagerAdapter
     /** Last seen cluster snapshot operation. */
     private volatile ClusterSnapshotFuture lastSeenSnpFut = new ClusterSnapshotFuture();
 
+    /** Snapshot operation handlers. */
+    private final SnapshotHandlers handlers = new SnapshotHandlers();
+
     /**
      * @param ctx Kernal context.
      */
@@ -381,6 +387,8 @@ public class IgniteSnapshotManager extends GridCacheSharedManagerAdapter
         U.ensureDirectory(locSnpDir, "snapshot work directory", log);
         U.ensureDirectory(tmpWorkDir, "temp directory for snapshot creation", log);
 
+        handlers.initialize(ctx, snpRunner);
+
         MetricRegistry mreg = cctx.kernalContext().metric().registry(SNAPSHOT_METRICS);
 
         mreg.register("LastSnapshotStartTime", () -> lastSeenSnpFut.startTime,
@@ -412,15 +420,21 @@ public class IgniteSnapshotManager extends GridCacheSharedManagerAdapter
 
                 if (evt.type() == EVT_NODE_LEFT || evt.type() == EVT_NODE_FAILED) {
                     SnapshotOperationRequest snpReq = clusterSnpReq;
+                    String err = "Snapshot operation interrupted, because baseline node left the cluster: " + leftNodeId;
+                    boolean reqNodeLeft = snpReq != null && snpReq.nodes().contains(leftNodeId);
+
+                    // If the coordinator left the cluster and did not start
+                    // the final snapshot phase (SNAPSHOT_END), we start it from a new one.
+                    if (reqNodeLeft && snpReq.startStageEnded() && U.isLocalNodeCoordinator(ctx.discovery())) {
+                        snpReq.error(new ClusterTopologyCheckedException(err));
+
+                        endSnpProc.start(snpReq.requestId(), snpReq);
+                    }
 
                     for (SnapshotFutureTask sctx : locSnpTasks.values()) {
                         if (sctx.sourceNodeId().equals(leftNodeId) ||
-                            (snpReq != null &&
-                                snpReq.snapshotName().equals(sctx.snapshotName()) &&
-                                snpReq.nodes().contains(leftNodeId))) {
-                            sctx.acceptException(new ClusterTopologyCheckedException("Snapshot operation interrupted. " +
-                                "One of baseline nodes left the cluster: " + leftNodeId));
-                        }
+                            (reqNodeLeft && snpReq.snapshotName().equals(sctx.snapshotName())))
+                            sctx.acceptException(new ClusterTopologyCheckedException(err));
                     }
 
                     restoreCacheGrpProc.onNodeLeft(leftNodeId);
@@ -654,22 +668,24 @@ public class IgniteSnapshotManager extends GridCacheSharedManagerAdapter
 
                 smf.getParentFile().mkdirs();
 
+                SnapshotMetadata meta = new SnapshotMetadata(req.requestId(),
+                    req.snapshotName(),
+                    cctx.localNode().consistentId().toString(),
+                    pdsSettings.folderName(),
+                    cctx.gridConfig().getDataStorageConfiguration().getPageSize(),
+                    grpIds,
+                    blts,
+                    fut.result());
+
                 try (OutputStream out = new BufferedOutputStream(new FileOutputStream(smf))) {
-                    U.marshal(marsh,
-                        new SnapshotMetadata(req.requestId(),
-                            req.snapshotName(),
-                            cctx.localNode().consistentId().toString(),
-                            pdsSettings.folderName(),
-                            cctx.gridConfig().getDataStorageConfiguration().getPageSize(),
-                            grpIds,
-                            blts,
-                            fut.result()),
-                        out);
+                    U.marshal(marsh, meta, out);
 
                     log.info("Snapshot metafile has been created: " + smf.getAbsolutePath());
                 }
 
-                return new SnapshotOperationResponse();
+                SnapshotHandlerContext ctx = new SnapshotHandlerContext(meta, req.groups(), cctx.localNode());
+
+                return new SnapshotOperationResponse(handlers.invokeAll(SnapshotHandlerType.CREATE, ctx));
             }
             catch (IOException | IgniteCheckedException e) {
                 throw F.wrap(e);
@@ -708,6 +724,8 @@ public class IgniteSnapshotManager extends GridCacheSharedManagerAdapter
             }
         }
 
+        snpReq.startStageEnded(true);
+
         if (isLocalNodeCoordinator(cctx.discovery())) {
             Set<UUID> missed = new HashSet<>(snpReq.nodes());
             missed.removeAll(res.keySet());
@@ -717,13 +735,71 @@ public class IgniteSnapshotManager extends GridCacheSharedManagerAdapter
                 snpReq.error(new IgniteFutureCancelledCheckedException("Execution of snapshot tasks " +
                     "has been cancelled by external process [err=" + err + ", missed=" + missed + ']'));
             }
-            else if (!F.isEmpty(err) || !missed.isEmpty()) {
-                snpReq.error(new IgniteCheckedException("Execution of local snapshot tasks fails or them haven't been executed " +
-                    "due to some of nodes left the cluster. Uncompleted snapshot will be deleted " +
-                    "[err=" + err + ", missed=" + missed + ']'));
+            else if (!missed.isEmpty()) {
+                snpReq.error(new ClusterTopologyCheckedException("Snapshot operation interrupted, because baseline " +
+                    "node left the cluster. Uncompleted snapshot will be deleted [missed=" + missed + ']'));
+            }
+            else if (!F.isEmpty(err)) {
+                snpReq.error(new IgniteCheckedException("Execution of local snapshot tasks fails. " +
+                    "Uncompleted snapshot will be deleted [err=" + err + ']'));
             }
 
-            endSnpProc.start(UUID.randomUUID(), snpReq);
+            completeHandlersAsyncIfNeeded(snpReq, res.values())
+                .listen(f -> {
+                        if (f.error() != null)
+                            snpReq.error(f.error());
+
+                        endSnpProc.start(snpReq.requestId(), snpReq);
+                    }
+                );
+        }
+    }
+
+    /**
+     * Execute the {@link SnapshotHandler#complete(String, Collection)} method of the snapshot handlers asynchronously.
+     *
+     * @param req Request on snapshot creation.
+     * @param res Results.
+     * @return Future that will be completed when the handlers are finished executing.
+     */
+    private IgniteInternalFuture<Void> completeHandlersAsyncIfNeeded(SnapshotOperationRequest req,
+        Collection<SnapshotOperationResponse> res) {
+        if (req.error() != null)
+            return new GridFinishedFuture<>();
+
+        Map<String, List<SnapshotHandlerResult<?>>> clusterHndResults = new HashMap<>();
+
+        for (SnapshotOperationResponse response : res) {
+            if (response == null || response.handlerResults() == null)
+                continue;
+
+            for (Map.Entry<String, SnapshotHandlerResult<Object>> entry : response.handlerResults().entrySet())
+                clusterHndResults.computeIfAbsent(entry.getKey(), v -> new ArrayList<>()).add(entry.getValue());
+        }
+
+        if (clusterHndResults.isEmpty())
+            return new GridFinishedFuture<>();
+
+        try {
+            GridFutureAdapter<Void> resultFut = new GridFutureAdapter<>();
+
+            handlers().execSvc.submit(() -> {
+                try {
+                    handlers.completeAll(SnapshotHandlerType.CREATE, req.snapshotName(), clusterHndResults, req.nodes());
+
+                    resultFut.onDone();
+                }
+                catch (Exception e) {
+                    log.warning("The snapshot operation will be aborted due to a handler error " +
+                        "[snapshot=" + req.snapshotName() + "].", e);
+
+                    resultFut.onDone(e);
+                }
+            });
+
+            return resultFut;
+        } catch (RejectedExecutionException e) {
+            return new GridFinishedFuture<>(e);
         }
     }
 
@@ -732,8 +808,10 @@ public class IgniteSnapshotManager extends GridCacheSharedManagerAdapter
      * @return Future which will be completed when the snapshot will be finalized.
      */
     private IgniteInternalFuture<SnapshotOperationResponse> initLocalSnapshotEndStage(SnapshotOperationRequest req) {
-        if (clusterSnpReq == null)
-            return new GridFinishedFuture<>(new SnapshotOperationResponse());
+        SnapshotOperationRequest snpReq = clusterSnpReq;
+
+        if (snpReq == null || !F.eq(req.requestId(), snpReq.requestId()))
+            return new GridFinishedFuture<>();
 
         try {
             if (req.error() != null)
@@ -756,7 +834,7 @@ public class IgniteSnapshotManager extends GridCacheSharedManagerAdapter
     private void processLocalSnapshotEndStageResult(UUID id, Map<UUID, SnapshotOperationResponse> res, Map<UUID, Exception> err) {
         SnapshotOperationRequest snpReq = clusterSnpReq;
 
-        if (snpReq == null)
+        if (snpReq == null || !F.eq(id, snpReq.requestId()))
             return;
 
         Set<UUID> endFail = new HashSet<>(snpReq.nodes());
@@ -942,7 +1020,8 @@ public class IgniteSnapshotManager extends GridCacheSharedManagerAdapter
 
     /**
      * @param name Snapshot name.
-     * @return {@code true} if snapshot is OK.
+     * @return Future with the result of execution snapshot partitions verify task, which besides calculating partition
+     *         hashes of {@link IdleVerifyResultV2} also contains the snapshot metadata distribution across the cluster.
      */
     public IgniteInternalFuture<IdleVerifyResultV2> checkSnapshot(String name) {
         A.notNullOrEmpty(name, "Snapshot name cannot be null or empty.");
@@ -950,7 +1029,7 @@ public class IgniteSnapshotManager extends GridCacheSharedManagerAdapter
 
         cctx.kernalContext().security().authorize(ADMIN_SNAPSHOT);
 
-        return checkSnapshot(name, null).chain(f -> {
+        return checkSnapshot(name, null, false).chain(f -> {
             try {
                 return f.get().idleVerifyResult();
             }
@@ -967,9 +1046,16 @@ public class IgniteSnapshotManager extends GridCacheSharedManagerAdapter
      *
      * @param name Snapshot name.
      * @param grps Collection of cache group names to check.
-     * @return {@code true} if snapshot is OK.
+     * @param includeCustomHandlers {@code True} to invoke all user-defined {@link SnapshotHandlerType#RESTORE}
+     *                              handlers, otherwise only system consistency check will be performed.
+     * @return Future with the result of execution snapshot partitions verify task, which besides calculating partition
+     *         hashes of {@link IdleVerifyResultV2} also contains the snapshot metadata distribution across the cluster.
      */
-    public IgniteInternalFuture<SnapshotPartitionsVerifyTaskResult> checkSnapshot(String name, @Nullable Collection<String> grps) {
+    public IgniteInternalFuture<SnapshotPartitionsVerifyTaskResult> checkSnapshot(
+        String name,
+        @Nullable Collection<String> grps,
+        boolean includeCustomHandlers
+    ) {
         A.notNullOrEmpty(name, "Snapshot name cannot be null or empty.");
         A.ensure(U.alphanumericUnderscore(name), "Snapshot name must satisfy the following name pattern: a-zA-Z0-9_");
         A.ensure(grps == null || grps.stream().filter(Objects::isNull).collect(Collectors.toSet()).isEmpty(),
@@ -1009,7 +1095,10 @@ public class IgniteSnapshotManager extends GridCacheSharedManagerAdapter
                 kctx0.task().setThreadContext(TC_SKIP_AUTH, true);
                 kctx0.task().setThreadContext(TC_SUBGRID, new ArrayList<>(metas.keySet()));
 
-                kctx0.task().execute(SnapshotPartitionsVerifyTask.class, new SnapshotPartitionsVerifyTaskArg(grps, metas))
+                Class<? extends AbstractSnapshotVerificationTask> cls =
+                    includeCustomHandlers ? SnapshotHandlerRestoreTask.class : SnapshotPartitionsVerifyTask.class;
+
+                kctx0.task().execute(cls, new SnapshotPartitionsVerifyTaskArg(grps, metas))
                     .listen(f1 -> {
                         if (f1.error() == null)
                             res.onDone(f1.result());
@@ -1654,6 +1743,128 @@ public class IgniteSnapshotManager extends GridCacheSharedManagerAdapter
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /** @return Snapshot handlers. */
+    protected SnapshotHandlers handlers() {
+        return handlers;
+    }
+
+    /** Snapshot operation handlers. */
+    protected static class SnapshotHandlers {
+        /** Snapshot operation handlers. */
+        private final Map<SnapshotHandlerType, List<SnapshotHandler<Object>>> handlers = new EnumMap<>(SnapshotHandlerType.class);
+
+        /** Executor service used to invoke handlers in parallel. */
+        private ExecutorService execSvc;
+
+        /**
+         * @param ctx Kernal context.
+         * @param execSvc Executor service used to invoke handlers in parallel.
+         */
+        private void initialize(GridKernalContext ctx, ExecutorService execSvc) {
+            this.execSvc = execSvc;
+
+            // Register system default snapshot integrity check that is used before the restore operation.
+            SnapshotHandler<?> sysCheck = new SnapshotPartitionsVerifyHandler(ctx.cache().context());
+            handlers.put(sysCheck.type(), new ArrayList<>(F.asList((SnapshotHandler<Object>)sysCheck)));
+
+            // Register custom handlers.
+            SnapshotHandler<Object>[] extHnds = (SnapshotHandler<Object>[])ctx.plugins().extensions(SnapshotHandler.class);
+
+            if (extHnds == null)
+                return;
+
+            for (SnapshotHandler<Object> extHnd : extHnds)
+                handlers.computeIfAbsent(extHnd.type(), v -> new ArrayList<>()).add(extHnd);
+        }
+
+        /**
+         * @param type Type of snapshot operation handler.
+         * @param ctx Snapshot operation handler context.
+         * @return Results from all handlers with the specified type.
+         * @throws IgniteCheckedException if parallel execution was failed.
+         */
+        protected @Nullable Map<String, SnapshotHandlerResult<Object>> invokeAll(
+            SnapshotHandlerType type,
+            SnapshotHandlerContext ctx
+        ) throws IgniteCheckedException {
+            List<SnapshotHandler<Object>> handlers = this.handlers.get(type);
+
+            if (F.isEmpty(handlers))
+                return null;
+
+            if (handlers.size() == 1) {
+                SnapshotHandler<Object> hnd = handlers.get(0);
+
+                return F.asMap(hnd.getClass().getName(), invoke(hnd, ctx));
+            }
+
+            return U.doInParallel(
+                execSvc,
+                handlers,
+                hnd -> new T2<>(hnd.getClass().getName(), invoke(hnd, ctx))
+            ).stream().collect(Collectors.toMap(T2::getKey, T2::getValue));
+        }
+
+        /***
+         * @param type Type of snapshot operation handler.
+         * @param snpName Snapshot name.
+         * @param res Results from all nodes and handlers with the specified type.
+         * @param reqNodes Node IDs on which the handlers were executed.
+         * @throws Exception If failed.
+         */
+        @SuppressWarnings({"rawtypes", "unchecked"})
+        protected void completeAll(
+            SnapshotHandlerType type,
+            String snpName,
+            Map<String, List<SnapshotHandlerResult<?>>> res,
+            Collection<UUID> reqNodes
+        ) throws Exception {
+            if (res.isEmpty())
+                return;
+
+            List<SnapshotHandler<Object>> hnds = handlers.get(type);
+
+            if (hnds == null || hnds.size() != res.size()) {
+                throw new IgniteCheckedException("Snapshot handlers configuration mismatch (number of local snapshot " +
+                    "handlers differs from the remote one). The current operation will be aborted " +
+                    "[locHnds=" + (hnds == null ? "" : F.viewReadOnly(hnds, h -> h.getClass().getName()).toString()) +
+                    ", rmtHnds=" + res.keySet() + "].");
+            }
+
+            for (SnapshotHandler hnd : hnds) {
+                List<SnapshotHandlerResult<?>> nodesRes = res.get(hnd.getClass().getName());
+
+                if (nodesRes == null || nodesRes.size() < reqNodes.size()) {
+                    Set<UUID> missing = new HashSet<>(reqNodes);
+
+                    if (nodesRes != null)
+                        missing.removeAll(F.viewReadOnly(nodesRes, r -> r.node().id()));
+
+                    throw new IgniteCheckedException("Snapshot handlers configuration mismatch, " +
+                        "\"" + hnd.getClass().getName() + "\" handler is missing on the remote node(s). " +
+                        "The current operation will be aborted [missing=" + missing + "].");
+                }
+
+                hnd.complete(snpName, nodesRes);
+            }
+        }
+
+        /**
+         * Creates a result by invocating the handler.
+         *
+         * @param hnd Snapshot operation handler.
+         * @param ctx Snapshot operation handler context.
+         */
+        private SnapshotHandlerResult<Object> invoke(SnapshotHandler<Object> hnd, SnapshotHandlerContext ctx) {
+            try {
+                return new SnapshotHandlerResult<>(hnd.invoke(ctx), null, ctx.localNode());
+            }
+            catch (Exception e) {
+                return new SnapshotHandlerResult<>(null, e, ctx.localNode());
+            }
+        }
+    }
+
     /**
      * Ves pokrit assertami absolutely ves,
      * PageScan iterator in the ignite core est.
@@ -2067,6 +2278,24 @@ public class IgniteSnapshotManager extends GridCacheSharedManagerAdapter
     private static class SnapshotOperationResponse implements Serializable {
         /** Serial version uid. */
         private static final long serialVersionUID = 0L;
+
+        /** Results of single-node handlers execution. */
+        private final Map<String, SnapshotHandlerResult<Object>> hndResults;
+
+        /** Default constructor. */
+        public SnapshotOperationResponse() {
+            this(null);
+        }
+
+        /** @param hndResults Results of single-node handlers execution.  */
+        public SnapshotOperationResponse(Map<String, SnapshotHandlerResult<Object>> hndResults) {
+            this.hndResults = hndResults;
+        }
+
+        /** @return Results of single-node handlers execution. */
+        public @Nullable Map<String, SnapshotHandlerResult<Object>> handlerResults() {
+            return hndResults;
+        }
     }
 
     /** Snapshot operation start message. */
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotHandler.java
new file mode 100644
index 0000000..6357c7d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotHandler.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.persistence.snapshot;
+
+import java.util.Collection;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.plugin.Extension;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Snapshot operation handler.
+ * <p>
+ * The execution of the handler consists of two steps:
+ * <ol>
+ * <li>Local call of {@link #invoke(SnapshotHandlerContext)} method on all nodes containing the snapshot data.</li>
+ * <li>Processing the results of local invocations in the {@link #complete(String, Collection)} method on one of the
+ * nodes containing the snapshot data.</li>
+ * </ol>
+ * Note: If during the execution of a snapshot operation some node exits, then whole operation is rolled back, in which
+ *       case the {@link #complete(String, Collection)} method may not be called.
+ *
+ * @param <T> Type of the local processing result.
+ */
+public interface SnapshotHandler<T> extends Extension {
+    /** Snapshot handler type. */
+    public SnapshotHandlerType type();
+
+    /**
+     * Local processing of a snapshot operation. Called on every node that contains snapshot data.
+     *
+     * @param ctx Snapshot handler context.
+     * @return Result of local processing. This result will be returned in {@link SnapshotHandlerResult#data()} method
+     *      passed into {@link #complete(String, Collection)} handler method.
+     * @throws Exception If invocation caused an exception. This exception will be returned in {@link
+     *      SnapshotHandlerResult#error()}} method passed into {@link #complete(String, Collection)} handler method.
+     */
+    public @Nullable T invoke(SnapshotHandlerContext ctx) throws Exception;
+
+    /**
+     * Processing the results of the {@link #invoke(SnapshotHandlerContext)} method received from all nodes. This method
+     * is called on coordinator node for {@link SnapshotHandlerType#CREATE} handler type and on the random node
+     * containing the snapshot data for {@link SnapshotHandlerType#RESTORE}.
+     * <p>
+     * Note: If this method fails, the entire cluster-wide snapshot operation will be aborted and the changes made by it
+     * will be rolled back.
+     *
+     * @param name Snapshot name.
+     * @param results Results from all nodes.
+     * @throws Exception If the snapshot operation needs to be aborted.
+     * @see SnapshotHandlerResult
+     */
+    public default void complete(String name, Collection<SnapshotHandlerResult<T>> results) throws Exception {
+        for (SnapshotHandlerResult<T> res : results) {
+            if (res.error() == null)
+                continue;
+
+            throw new IgniteCheckedException("Snapshot handler has failed. " + res.error().getMessage() +
+                " [snapshot=" + name +
+                ", handler=" + getClass().getName() +
+                ", nodeId=" + res.node().id() + "].", res.error());
+        }
+    }
+}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotHandlerContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotHandlerContext.java
new file mode 100644
index 0000000..3cdf715
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotHandlerContext.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.persistence.snapshot;
+
+import java.util.Collection;
+import org.apache.ignite.cluster.ClusterNode;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Snapshot operation handler context.
+ */
+public class SnapshotHandlerContext {
+    /** Snapshot metadata. */
+    private final SnapshotMetadata metadata;
+
+    /** The names of the cache groups on which the operation is performed. */
+    private final Collection<String> grps;
+
+    /** Local node. */
+    private final ClusterNode locNode;
+
+    /**
+     * @param metadata Snapshot metadata.
+     * @param grps The names of the cache groups on which the operation is performed.
+     * @param locNode Local node.
+     */
+    public SnapshotHandlerContext(SnapshotMetadata metadata, @Nullable Collection<String> grps, ClusterNode locNode) {
+        this.metadata = metadata;
+        this.grps = grps;
+        this.locNode = locNode;
+    }
+
+    /**
+     * @return Snapshot metadata.
+     */
+    public SnapshotMetadata metadata() {
+        return metadata;
+    }
+
+    /**
+     * @return The names of the cache groups on which the operation is performed. May be {@code null} if the operation
+     * is performed on all available cache groups.
+     */
+    public @Nullable Collection<String> groups() {
+        return grps;
+    }
+
+    /**
+     * @return Local node.
+     */
+    public ClusterNode localNode() {
+        return locNode;
+    }
+}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotHandlerRestoreTask.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotHandlerRestoreTask.java
new file mode 100644
index 0000000..4bbb5e9
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotHandlerRestoreTask.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.persistence.snapshot;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.resources.LoggerResource;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Snapshot restore operation handling task.
+ */
+public class SnapshotHandlerRestoreTask extends AbstractSnapshotVerificationTask {
+    /** Serial version uid. */
+    private static final long serialVersionUID = 0L;
+
+    /** Injected ignite logger. */
+    @LoggerResource
+    private IgniteLogger log;
+
+    /** {@inheritDoc} */
+    @Override protected ComputeJob createJob(String snpName, String constId, Collection<String> groups) {
+        return new SnapshotHandlerRestoreJob(snpName, constId, groups);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("rawtypes")
+    @Nullable @Override public SnapshotPartitionsVerifyTaskResult reduce(List<ComputeJobResult> results) {
+        Map<String, List<SnapshotHandlerResult<?>>> clusterResults = new HashMap<>();
+        Collection<UUID> execNodes = new ArrayList<>(results.size());
+
+        for (ComputeJobResult res : results) {
+            if (res.getException() != null)
+                throw res.getException();
+
+            // Depending on the job mapping, we can get several different results from one node.
+            execNodes.add(res.getNode().id());
+
+            Map<String, SnapshotHandlerResult> nodeDataMap = res.getData();
+
+            assert nodeDataMap != null : "At least the default snapshot restore handler should have been executed ";
+
+            for (Map.Entry<String, SnapshotHandlerResult> entry : nodeDataMap.entrySet()) {
+                String hndName = entry.getKey();
+
+                clusterResults.computeIfAbsent(hndName, v -> new ArrayList<>()).add(entry.getValue());
+            }
+        }
+
+        String snapshotName = F.first(F.first(metas.values())).snapshotName();
+
+        try {
+            ignite.context().cache().context().snapshotMgr().handlers().completeAll(
+                SnapshotHandlerType.RESTORE, snapshotName, clusterResults, execNodes);
+        } catch (Exception e) {
+            log.warning("The snapshot operation will be aborted due to a handler error [snapshot=" + snapshotName + "].", e);
+
+            throw new IgniteException(e);
+        }
+
+        return new SnapshotPartitionsVerifyTaskResult(metas, null);
+    }
+
+    /** Invokes all {@link SnapshotHandlerType#RESTORE} handlers locally. */
+    private static class SnapshotHandlerRestoreJob extends ComputeJobAdapter {
+        /** Serial version uid. */
+        private static final long serialVersionUID = 0L;
+
+        /** Ignite instance. */
+        @IgniteInstanceResource
+        private IgniteEx ignite;
+
+        /** Injected logger. */
+        @LoggerResource
+        private IgniteLogger log;
+
+        /** Snapshot name. */
+        private final String snpName;
+
+        /** String representation of the consistent node ID. */
+        private final String consistentId;
+
+        /** Cache group names. */
+        private final Collection<String> grps;
+
+        /**
+         * @param snpName Snapshot name.
+         * @param consistentId String representation of the consistent node ID.
+         * @param grps Cache group names.
+         */
+        public SnapshotHandlerRestoreJob(String snpName, String consistentId, Collection<String> grps) {
+            this.snpName = snpName;
+            this.consistentId = consistentId;
+            this.grps = grps;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Map<String, SnapshotHandlerResult<Object>> execute() {
+            try {
+                IgniteSnapshotManager snpMgr = ignite.context().cache().context().snapshotMgr();
+                SnapshotMetadata meta = snpMgr.readSnapshotMetadata(snpName, consistentId);
+                SnapshotHandlerContext ctx = new SnapshotHandlerContext(meta, grps, ignite.localNode());
+
+                return snpMgr.handlers().invokeAll(SnapshotHandlerType.RESTORE, ctx);
+            }
+            catch (IgniteCheckedException e) {
+                throw new IgniteException(e);
+            }
+        }
+    }
+}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotHandlerResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotHandlerResult.java
new file mode 100644
index 0000000..b924328
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotHandlerResult.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.persistence.snapshot;
+
+import java.io.Serializable;
+import org.apache.ignite.cluster.ClusterNode;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Result of local processing on the node. In addition to the result received from the handler, it also includes
+ * information about the error (if any) and the node on which this result was received.
+ *
+ * @param <T> Type of the local processing result.
+ */
+public class SnapshotHandlerResult<T> implements Serializable {
+    /** Serial version uid. */
+    private static final long serialVersionUID = 0L;
+
+    /** Result of local processing. */
+    private final T data;
+
+    /** Processing error. */
+    private final Exception err;
+
+    /** Processing node. */
+    private final ClusterNode node;
+
+    /**
+     * @param data Result of local processing.
+     * @param err Processing error.
+     * @param node Processing node.
+     */
+    public SnapshotHandlerResult(@Nullable T data, @Nullable Exception err, ClusterNode node) {
+        this.data = data;
+        this.err = err;
+        this.node = node;
+    }
+
+    /** @return Result of local processing. */
+    public @Nullable T data() {
+        return data;
+    }
+
+    /** @return Processing error. */
+    public @Nullable Exception error() {
+        return err;
+    }
+
+    /** @return Processing node. */
+    public ClusterNode node() {
+        return node;
+    }
+}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotHandlerType.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotHandlerType.java
new file mode 100644
index 0000000..5d46bd7
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotHandlerType.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.persistence.snapshot;
+
+/**
+ * Type of snapshot operation handler.
+ */
+public enum SnapshotHandlerType {
+    /** Handler is called immediately after the snapshot is taken. */
+    CREATE,
+
+    /** Handler is called just before restore operation is started. */
+    RESTORE
+}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotOperationRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotOperationRequest.java
index 177133f..4cbcb57 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotOperationRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotOperationRequest.java
@@ -22,6 +22,7 @@ import java.util.Collection;
 import java.util.Set;
 import java.util.UUID;
 import org.apache.ignite.internal.util.distributed.DistributedProcess;
+import org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.jetbrains.annotations.Nullable;
@@ -53,6 +54,9 @@ public class SnapshotOperationRequest implements Serializable {
     /** Exception occurred during snapshot operation processing. */
     private volatile Throwable err;
 
+    /** Flag indicating that the {@link DistributedProcessType#START_SNAPSHOT} phase has completed. */
+    private transient volatile boolean startStageEnded;
+
     /**
      * @param reqId Request ID.
      * @param opNodeId Operational node ID.
@@ -123,6 +127,20 @@ public class SnapshotOperationRequest implements Serializable {
         this.err = err;
     }
 
+    /**
+     * @return Flag indicating that the {@link DistributedProcessType#START_SNAPSHOT} phase has completed.
+     */
+    protected boolean startStageEnded() {
+        return startStageEnded;
+    }
+
+    /**
+     * @param startStageEnded Flag indicating that the {@link DistributedProcessType#START_SNAPSHOT} phase has completed.
+     */
+    protected void startStageEnded(boolean startStageEnded) {
+        this.startStageEnded = startStageEnded;
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(SnapshotOperationRequest.class, this);
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyHandler.java
new file mode 100644
index 0000000..a227f66
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyHandler.java
@@ -0,0 +1,252 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.persistence.snapshot;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Collectors;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.GridComponent;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
+import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState;
+import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStore;
+import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager;
+import org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage;
+import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO;
+import org.apache.ignite.internal.processors.cache.persistence.tree.io.PagePartitionMetaIO;
+import org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2;
+import org.apache.ignite.internal.processors.cache.verify.PartitionHashRecordV2;
+import org.apache.ignite.internal.processors.cache.verify.PartitionKeyV2;
+import org.apache.ignite.internal.util.GridStringBuilder;
+import org.apache.ignite.internal.util.GridUnsafe;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.CU;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
+import static org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_DATA;
+import static org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_IDX;
+import static org.apache.ignite.internal.pagemem.PageIdAllocator.INDEX_PARTITION;
+import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.OWNING;
+import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.fromOrdinal;
+import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.cacheGroupName;
+import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.cachePartitionFiles;
+import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.partId;
+import static org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId.getTypeByPartId;
+import static org.apache.ignite.internal.processors.cache.verify.IdleVerifyUtility.calculatePartitionHash;
+import static org.apache.ignite.internal.processors.cache.verify.IdleVerifyUtility.checkPartitionsPageCrcSum;
+
+/**
+ * Default snapshot restore handler for checking snapshot partitions consistency.
+ */
+public class SnapshotPartitionsVerifyHandler implements SnapshotHandler<Map<PartitionKeyV2, PartitionHashRecordV2>> {
+    /** Shared context. */
+    private final GridCacheSharedContext<?, ?> cctx;
+
+    /** Logger. */
+    private final IgniteLogger log;
+
+    /** @param cctx Shared context. */
+    public SnapshotPartitionsVerifyHandler(GridCacheSharedContext<?, ?> cctx) {
+        this.cctx = cctx;
+
+        log = cctx.logger(getClass());
+    }
+
+    /** {@inheritDoc} */
+    @Override public SnapshotHandlerType type() {
+        return SnapshotHandlerType.RESTORE;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Map<PartitionKeyV2, PartitionHashRecordV2> invoke(SnapshotHandlerContext opCtx) throws IgniteCheckedException {
+        SnapshotMetadata meta = opCtx.metadata();
+
+        Set<Integer> grps = F.isEmpty(opCtx.groups()) ? new HashSet<>(meta.partitions().keySet()) :
+            opCtx.groups().stream().map(CU::cacheId).collect(Collectors.toSet());
+
+        Set<File> partFiles = new HashSet<>();
+
+        IgniteSnapshotManager snpMgr = cctx.snapshotMgr();
+
+        for (File dir : snpMgr.snapshotCacheDirectories(meta.snapshotName(), meta.folderName())) {
+            int grpId = CU.cacheId(cacheGroupName(dir));
+
+            if (!grps.remove(grpId))
+                continue;
+
+            Set<Integer> parts = new HashSet<>(meta.partitions().get(grpId));
+
+            for (File part : cachePartitionFiles(dir)) {
+                int partId = partId(part.getName());
+
+                if (!parts.remove(partId))
+                    continue;
+
+                partFiles.add(part);
+            }
+
+            if (!parts.isEmpty()) {
+                throw new IgniteException("Snapshot data doesn't contain required cache group partition " +
+                    "[grpId=" + grpId + ", snpName=" + meta.snapshotName() + ", consId=" + meta.consistentId() +
+                    ", missed=" + parts + ", meta=" + meta + ']');
+            }
+        }
+
+        if (!grps.isEmpty()) {
+            throw new IgniteException("Snapshot data doesn't contain required cache groups " +
+                "[grps=" + grps + ", snpName=" + meta.snapshotName() + ", consId=" + meta.consistentId() +
+                ", meta=" + meta + ']');
+        }
+
+        Map<PartitionKeyV2, PartitionHashRecordV2> res = new ConcurrentHashMap<>();
+        ThreadLocal<ByteBuffer> buff = ThreadLocal.withInitial(() -> ByteBuffer.allocateDirect(meta.pageSize())
+            .order(ByteOrder.nativeOrder()));
+
+        GridKernalContext snpCtx = snpMgr.createStandaloneKernalContext(meta.snapshotName(), meta.folderName());
+
+        for (GridComponent comp : snpCtx)
+            comp.start();
+
+        try {
+            U.doInParallel(
+                snpMgr.snapshotExecutorService(),
+                partFiles,
+                part -> {
+                    String grpName = cacheGroupName(part.getParentFile());
+                    int grpId = CU.cacheId(grpName);
+                    int partId = partId(part.getName());
+
+                    FilePageStoreManager storeMgr = (FilePageStoreManager)cctx.pageStore();
+
+                    try (FilePageStore pageStore = (FilePageStore)storeMgr.getPageStoreFactory(grpId, false)
+                        .createPageStore(getTypeByPartId(partId),
+                            part::toPath,
+                            val -> {
+                            })
+                    ) {
+                        if (partId == INDEX_PARTITION) {
+                            checkPartitionsPageCrcSum(() -> pageStore, INDEX_PARTITION, FLAG_IDX);
+
+                            return null;
+                        }
+
+                        if (grpId == MetaStorage.METASTORAGE_CACHE_ID) {
+                            checkPartitionsPageCrcSum(() -> pageStore, partId, FLAG_DATA);
+
+                            return null;
+                        }
+
+                        ByteBuffer pageBuff = buff.get();
+                        pageBuff.clear();
+                        pageStore.read(0, pageBuff, true);
+
+                        long pageAddr = GridUnsafe.bufferAddress(pageBuff);
+
+                        PagePartitionMetaIO io = PageIO.getPageIO(pageBuff);
+                        GridDhtPartitionState partState = fromOrdinal(io.getPartitionState(pageAddr));
+
+                        if (partState != OWNING) {
+                            throw new IgniteCheckedException("Snapshot partitions must be in the OWNING " +
+                                "state only: " + partState);
+                        }
+
+                        long updateCntr = io.getUpdateCounter(pageAddr);
+                        long size = io.getSize(pageAddr);
+
+                        if (log.isDebugEnabled()) {
+                            log.debug("Partition [grpId=" + grpId
+                                + ", id=" + partId
+                                + ", counter=" + updateCntr
+                                + ", size=" + size + "]");
+                        }
+
+                        // Snapshot partitions must always be in OWNING state.
+                        // There is no `primary` partitions for snapshot.
+                        PartitionKeyV2 key = new PartitionKeyV2(grpId, partId, grpName);
+
+                        PartitionHashRecordV2 hash = calculatePartitionHash(key,
+                            updateCntr,
+                            meta.consistentId(),
+                            GridDhtPartitionState.OWNING,
+                            false,
+                            size,
+                            snpMgr.partitionRowIterator(snpCtx, grpName, partId, pageStore));
+
+                        assert hash != null : "OWNING must have hash: " + key;
+
+                        res.put(key, hash);
+                    }
+                    catch (IOException e) {
+                        throw new IgniteCheckedException(e);
+                    }
+
+                    return null;
+                }
+            );
+        }
+        finally {
+            for (GridComponent comp : snpCtx)
+                comp.stop(true);
+        }
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void complete(String name,
+        Collection<SnapshotHandlerResult<Map<PartitionKeyV2, PartitionHashRecordV2>>> results) throws IgniteCheckedException {
+        Map<PartitionKeyV2, List<PartitionHashRecordV2>> clusterHashes = new HashMap<>();
+        Map<ClusterNode, Exception> errs = new HashMap<>();
+
+        for (SnapshotHandlerResult<Map<PartitionKeyV2, PartitionHashRecordV2>> res : results) {
+            if (res.error() != null) {
+                errs.put(res.node(), res.error());
+
+                continue;
+            }
+
+            for (Map.Entry<PartitionKeyV2, PartitionHashRecordV2> entry : res.data().entrySet())
+                clusterHashes.computeIfAbsent(entry.getKey(), v -> new ArrayList<>()).add(entry.getValue());
+        }
+
+        IdleVerifyResultV2 verifyResult = new IdleVerifyResultV2(clusterHashes, errs);
+
+        if (errs.isEmpty() && !verifyResult.hasConflicts())
+            return;
+
+        GridStringBuilder buf = new GridStringBuilder();
+
+        verifyResult.print(buf::a, true);
+
+        throw new IgniteCheckedException(buf.toString());
+    }
+}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyTask.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyTask.java
index 0e99e8c..040802f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyTask.java
@@ -17,62 +17,26 @@
 
 package org.apache.ignite.internal.processors.cache.persistence.snapshot;
 
-import java.io.File;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.stream.Collectors;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.compute.ComputeJob;
 import org.apache.ignite.compute.ComputeJobAdapter;
 import org.apache.ignite.compute.ComputeJobResult;
-import org.apache.ignite.compute.ComputeJobResultPolicy;
-import org.apache.ignite.compute.ComputeTaskAdapter;
-import org.apache.ignite.internal.GridComponent;
-import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.IgniteEx;
-import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState;
-import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStore;
-import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager;
-import org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage;
-import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO;
-import org.apache.ignite.internal.processors.cache.persistence.tree.io.PagePartitionMetaIO;
+import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.verify.PartitionHashRecordV2;
 import org.apache.ignite.internal.processors.cache.verify.PartitionKeyV2;
 import org.apache.ignite.internal.processors.cache.verify.VerifyBackupPartitionsTaskV2;
 import org.apache.ignite.internal.processors.task.GridInternal;
-import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.CU;
-import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.resources.IgniteInstanceResource;
 import org.apache.ignite.resources.LoggerResource;
-import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
-import static org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_DATA;
-import static org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_IDX;
-import static org.apache.ignite.internal.pagemem.PageIdAllocator.INDEX_PARTITION;
-import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.OWNING;
-import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.fromOrdinal;
-import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.cacheGroupName;
-import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.cachePartitionFiles;
-import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.partId;
-import static org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId.getTypeByPartId;
-import static org.apache.ignite.internal.processors.cache.verify.IdleVerifyUtility.calculatePartitionHash;
-import static org.apache.ignite.internal.processors.cache.verify.IdleVerifyUtility.checkPartitionsPageCrcSum;
 import static org.apache.ignite.internal.processors.cache.verify.VerifyBackupPartitionsTaskV2.reduce0;
 
 /**
@@ -81,71 +45,17 @@ import static org.apache.ignite.internal.processors.cache.verify.VerifyBackupPar
  * to be hold on.
  */
 @GridInternal
-public class SnapshotPartitionsVerifyTask
-    extends ComputeTaskAdapter<SnapshotPartitionsVerifyTaskArg, SnapshotPartitionsVerifyTaskResult> {
+public class SnapshotPartitionsVerifyTask extends AbstractSnapshotVerificationTask {
     /** Serial version uid. */
     private static final long serialVersionUID = 0L;
 
-    /** Task argument. */
-    private final Map<ClusterNode, List<SnapshotMetadata>> metas = new HashMap<>();
-
     /** Ignite instance. */
     @IgniteInstanceResource
     private IgniteEx ignite;
 
     /** {@inheritDoc} */
-    @Override public @NotNull Map<? extends ComputeJob, ClusterNode> map(
-        List<ClusterNode> subgrid,
-        @Nullable SnapshotPartitionsVerifyTaskArg arg
-    ) throws IgniteException {
-        Map<ClusterNode, List<SnapshotMetadata>> clusterMetas = arg.clusterMetadata();
-
-        if (!subgrid.containsAll(clusterMetas.keySet())) {
-            throw new IgniteSnapshotVerifyException(F.asMap(ignite.localNode(),
-                new IgniteException("Some of Ignite nodes left the cluster during the snapshot verification " +
-                "[curr=" + F.viewReadOnly(subgrid, F.node2id()) +
-                ", init=" + F.viewReadOnly(clusterMetas.keySet(), F.node2id()) + ']')));
-        }
-
-        Map<ComputeJob, ClusterNode> jobs = new HashMap<>();
-        Set<SnapshotMetadata> allMetas = new HashSet<>();
-        clusterMetas.values().forEach(allMetas::addAll);
-
-        Set<String> missed = null;
-
-        for (SnapshotMetadata meta : allMetas) {
-            if (missed == null)
-                missed = new HashSet<>(meta.baselineNodes());
-
-            missed.remove(meta.consistentId());
-
-            if (missed.isEmpty())
-                break;
-        }
-
-        if (!missed.isEmpty()) {
-            throw new IgniteSnapshotVerifyException(F.asMap(ignite.localNode(),
-                new IgniteException("Some metadata is missing from the snapshot: " + missed)));
-        }
-
-        metas.putAll(clusterMetas);
-
-        while (!allMetas.isEmpty()) {
-            for (Map.Entry<ClusterNode, List<SnapshotMetadata>> e : clusterMetas.entrySet()) {
-                SnapshotMetadata meta = F.find(e.getValue(), null, allMetas::remove);
-
-                if (meta == null)
-                    continue;
-
-                jobs.put(new VisorVerifySnapshotPartitionsJob(meta.snapshotName(), meta.consistentId(), arg.cacheGroupNames()),
-                    e.getKey());
-
-                if (allMetas.isEmpty())
-                    break;
-            }
-        }
-
-        return jobs;
+    @Override protected ComputeJob createJob(String name, String constId, Collection<String> groups) {
+        return new VisorVerifySnapshotPartitionsJob(name, constId, groups);
     }
 
     /** {@inheritDoc} */
@@ -153,12 +63,6 @@ public class SnapshotPartitionsVerifyTask
         return new SnapshotPartitionsVerifyTaskResult(metas, reduce0(results));
     }
 
-    /** {@inheritDoc} */
-    @Override public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult> rcvd) throws IgniteException {
-        // Handle all exceptions during the `reduce` operation.
-        return ComputeJobResultPolicy.WAIT;
-    }
-
     /** Job that collects update counters of snapshot partitions on the node it executes. */
     private static class VisorVerifySnapshotPartitionsJob extends ComputeJobAdapter {
         /** Serial version uid. */
@@ -179,7 +83,7 @@ public class SnapshotPartitionsVerifyTask
         private final String consId;
 
         /** Set of cache groups to be checked in the snapshot or {@code empty} to check everything. */
-        private final Set<String> rqGrps;
+        private final Collection<String> rqGrps;
 
         /**
          * @param snpName Snapshot name to validate.
@@ -189,150 +93,27 @@ public class SnapshotPartitionsVerifyTask
         public VisorVerifySnapshotPartitionsJob(String snpName, String consId, Collection<String> rqGrps) {
             this.snpName = snpName;
             this.consId = consId;
-
-            this.rqGrps = rqGrps == null ? Collections.emptySet() : new HashSet<>(rqGrps);
+            this.rqGrps = rqGrps;
         }
 
+        /** {@inheritDoc} */
         @Override public Map<PartitionKeyV2, PartitionHashRecordV2> execute() throws IgniteException {
-            IgniteSnapshotManager snpMgr = ignite.context().cache().context().snapshotMgr();
+            GridCacheSharedContext<?, ?> cctx = ignite.context().cache().context();
 
             if (log.isInfoEnabled()) {
                 log.info("Verify snapshot partitions procedure has been initiated " +
                     "[snpName=" + snpName + ", consId=" + consId + ']');
             }
 
-            SnapshotMetadata meta = snpMgr.readSnapshotMetadata(snpName, consId);
-            Set<Integer> grps = rqGrps.isEmpty() ? new HashSet<>(meta.partitions().keySet()) :
-                rqGrps.stream().map(CU::cacheId).collect(Collectors.toSet());
-            Set<File> partFiles = new HashSet<>();
-
-            for (File dir : snpMgr.snapshotCacheDirectories(snpName, meta.folderName())) {
-                int grpId = CU.cacheId(cacheGroupName(dir));
-
-                if (!grps.remove(grpId))
-                    continue;
-
-                Set<Integer> parts = new HashSet<>(meta.partitions().get(grpId));
-
-                for (File part : cachePartitionFiles(dir)) {
-                    int partId = partId(part.getName());
-
-                    if (!parts.remove(partId))
-                        continue;
-
-                    partFiles.add(part);
-                }
-
-                if (!parts.isEmpty()) {
-                    throw new IgniteException("Snapshot data doesn't contain required cache group partition " +
-                        "[grpId=" + grpId + ", snpName=" + snpName + ", consId=" + consId +
-                        ", missed=" + parts + ", meta=" + meta + ']');
-                }
-            }
-
-            if (!grps.isEmpty()) {
-                throw new IgniteException("Snapshot data doesn't contain required cache groups " +
-                    "[grps=" + grps + ", snpName=" + snpName + ", consId=" + consId +
-                    ", meta=" + meta + ']');
-            }
-
-            Map<PartitionKeyV2, PartitionHashRecordV2> res = new ConcurrentHashMap<>();
-            ThreadLocal<ByteBuffer> buff = ThreadLocal.withInitial(() -> ByteBuffer.allocateDirect(meta.pageSize())
-                .order(ByteOrder.nativeOrder()));
-
             try {
-                GridKernalContext snpCtx = snpMgr.createStandaloneKernalContext(snpName, meta.folderName());
-
-                for (GridComponent comp : snpCtx)
-                    comp.start();
-
-                try {
-                    U.doInParallel(
-                        snpMgr.snapshotExecutorService(),
-                        partFiles,
-                        part -> {
-                            String grpName = cacheGroupName(part.getParentFile());
-                            int grpId = CU.cacheId(grpName);
-                            int partId = partId(part.getName());
-
-                            FilePageStoreManager storeMgr = (FilePageStoreManager)ignite.context().cache().context().pageStore();
-
-                            try (FilePageStore pageStore = (FilePageStore)storeMgr.getPageStoreFactory(grpId, false)
-                                .createPageStore(getTypeByPartId(partId),
-                                    part::toPath,
-                                    val -> {
-                                    })
-                            ) {
-                                if (partId == INDEX_PARTITION) {
-                                    checkPartitionsPageCrcSum(() -> pageStore, INDEX_PARTITION, FLAG_IDX);
-
-                                    return null;
-                                }
+                SnapshotMetadata meta = cctx.snapshotMgr().readSnapshotMetadata(snpName, consId);
 
-                                if (grpId == MetaStorage.METASTORAGE_CACHE_ID) {
-                                    checkPartitionsPageCrcSum(() -> pageStore, partId, FLAG_DATA);
-
-                                    return null;
-                                }
-
-                                ByteBuffer pageBuff = buff.get();
-                                pageBuff.clear();
-                                pageStore.read(0, pageBuff, true);
-
-                                long pageAddr = GridUnsafe.bufferAddress(pageBuff);
-
-                                PagePartitionMetaIO io = PageIO.getPageIO(pageBuff);
-                                GridDhtPartitionState partState = fromOrdinal(io.getPartitionState(pageAddr));
-
-                                if (partState != OWNING) {
-                                    throw new IgniteCheckedException("Snapshot partitions must be in the OWNING " +
-                                        "state only: " + partState);
-                                }
-
-                                long updateCntr = io.getUpdateCounter(pageAddr);
-                                long size = io.getSize(pageAddr);
-
-                                if (log.isDebugEnabled()) {
-                                    log.debug("Partition [grpId=" + grpId
-                                        + ", id=" + partId
-                                        + ", counter=" + updateCntr
-                                        + ", size=" + size + "]");
-                                }
-
-                                // Snapshot partitions must always be in OWNING state.
-                                // There is no `primary` partitions for snapshot.
-                                PartitionKeyV2 key = new PartitionKeyV2(grpId, partId, grpName);
-
-                                PartitionHashRecordV2 hash = calculatePartitionHash(key,
-                                    updateCntr,
-                                    consId,
-                                    GridDhtPartitionState.OWNING,
-                                    false,
-                                    size,
-                                    snpMgr.partitionRowIterator(snpCtx, grpName, partId, pageStore));
-
-                                assert hash != null : "OWNING must have hash: " + key;
-
-                                res.put(key, hash);
-                            }
-                            catch (IOException e) {
-                                throw new IgniteCheckedException(e);
-                            }
-
-                            return null;
-                        }
-                    );
-                }
-                finally {
-                    for (GridComponent comp : snpCtx)
-                        comp.stop(true);
-                }
+                return new SnapshotPartitionsVerifyHandler(cctx)
+                    .invoke(new SnapshotHandlerContext(meta, rqGrps, ignite.localNode()));
             }
             catch (IgniteCheckedException e) {
                 throw new IgniteException(e);
             }
-
-            return res;
         }
 
         /** {@inheritDoc} */
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
index 49c9c76..8589748 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
@@ -54,7 +54,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.StoredCacheData;
 import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager;
 import org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.ClusterSnapshotFuture;
-import org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2;
 import org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState;
 import org.apache.ignite.internal.util.distributed.DistributedProcess;
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
@@ -223,7 +222,7 @@ public class SnapshotRestoreProcess {
 
         snpMgr.recordSnapshotEvent(snpName, msg, EventType.EVT_CLUSTER_SNAPSHOT_RESTORE_STARTED);
 
-        snpMgr.checkSnapshot(snpName, cacheGrpNames).listen(f -> {
+        snpMgr.checkSnapshot(snpName, cacheGrpNames, true).listen(f -> {
             if (f.error() != null) {
                 finishProcess(fut0.rqId, f.error());
 
@@ -290,18 +289,6 @@ public class SnapshotRestoreProcess {
                 return;
             }
 
-            IdleVerifyResultV2 res = f.result().idleVerifyResult();
-
-            if (!F.isEmpty(res.exceptions()) || res.hasConflicts()) {
-                StringBuilder sb = new StringBuilder();
-
-                res.print(sb::append, true);
-
-                finishProcess(fut0.rqId, new IgniteException(sb.toString()));
-
-                return;
-            }
-
             SnapshotOperationRequest req =
                 new SnapshotOperationRequest(fut0.rqId, F.first(dataNodes), snpName, cacheGrpNames, dataNodes);
 
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotCheckTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotCheckTest.java
index b724e91..9696615 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotCheckTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotCheckTest.java
@@ -598,7 +598,7 @@ public class IgniteClusterSnapshotCheckTest extends AbstractSnapshotSelfTest {
 
         corruptPartitionFile(ignite, SNAPSHOT_NAME, ccfg1, PART_ID);
 
-        return snp(ignite).checkSnapshot(SNAPSHOT_NAME, cachesToCheck).get(TIMEOUT);
+        return snp(ignite).checkSnapshot(SNAPSHOT_NAME, cachesToCheck, false).get(TIMEOUT);
     }
 
     /**
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotHandlerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotHandlerTest.java
new file mode 100644
index 0000000..6f87fd5
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotHandlerTest.java
@@ -0,0 +1,351 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.persistence.snapshot;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.Function;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.marshaller.MarshallerUtils;
+import org.apache.ignite.plugin.AbstractTestPluginProvider;
+import org.apache.ignite.plugin.ExtensionRegistry;
+import org.apache.ignite.plugin.PluginConfiguration;
+import org.apache.ignite.plugin.PluginContext;
+import org.apache.ignite.plugin.PluginProvider;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.jetbrains.annotations.Nullable;
+import org.junit.Test;
+
+import static org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.SNAPSHOT_METAFILE_EXT;
+
+/**
+ * Snapshot custom handlers test.
+ */
+public class IgniteClusterSnapshotHandlerTest extends IgniteClusterSnapshotRestoreBaseTest {
+    /** Custom snapshot handlers. */
+    private final List<SnapshotHandler<?>> handlers = new ArrayList<>();
+
+    /** Extensions plugin provider. */
+    private final PluginProvider<PluginConfiguration> pluginProvider = new AbstractTestPluginProvider() {
+        @Override public String name() {
+            return "SnapshotVerifier";
+        }
+
+        @Override public void initExtensions(PluginContext ctx, ExtensionRegistry registry) {
+            for (SnapshotHandler<?> hnd : handlers)
+                registry.registerExtension(SnapshotHandler.class, hnd);
+        }
+    };
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+        return super.getConfiguration(igniteInstanceName).setPluginProviders(pluginProvider);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected Function<Integer, Object> valueBuilder() {
+        return Integer::new;
+    }
+
+    /**
+     * Test the basic snapshot metadata consistency using handlers.
+     *
+     * @throws Exception If fails.
+     */
+    @Test
+    public void testClusterSnapshotHandlers() throws Exception {
+        String expMsg = "Inconsistent data";
+
+        AtomicReference<UUID> reqIdRef = new AtomicReference<>();
+
+        handlers.add(new SnapshotHandler<UUID>() {
+            @Override public SnapshotHandlerType type() {
+                return SnapshotHandlerType.CREATE;
+            }
+
+            @Override public UUID invoke(SnapshotHandlerContext ctx) {
+                return ctx.metadata().requestId();
+            }
+
+            @Override public void complete(String name,
+                Collection<SnapshotHandlerResult<UUID>> results) throws IgniteCheckedException {
+                for (SnapshotHandlerResult<UUID> res : results) {
+                    if (!reqIdRef.compareAndSet(null, res.data()) && !reqIdRef.get().equals(res.data()))
+                        throw new IgniteCheckedException("The request ID must be the same on all nodes.");
+                }
+            }
+        });
+
+        handlers.add(new SnapshotHandler<UUID>() {
+            @Override public SnapshotHandlerType type() {
+                return SnapshotHandlerType.RESTORE;
+            }
+
+            @Override public UUID invoke(SnapshotHandlerContext ctx) {
+                return ctx.metadata().requestId();
+            }
+
+            @Override public void complete(String name,
+                Collection<SnapshotHandlerResult<UUID>> results) throws IgniteCheckedException {
+                for (SnapshotHandlerResult<UUID> res : results) {
+                    if (!reqIdRef.get().equals(res.data()))
+                        throw new IgniteCheckedException(expMsg);
+                }
+            }
+        });
+
+        IgniteEx ignite = startGridsWithSnapshot(2, CACHE_KEYS_RANGE);
+
+        assertNotNull(reqIdRef.get());
+
+        changeMetadataRequestIdOnDisk(UUID.randomUUID());
+
+        IgniteFuture<Void> fut = ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, null);
+
+        GridTestUtils.assertThrowsAnyCause(log, () -> fut.get(TIMEOUT), IgniteCheckedException.class, expMsg);
+
+        changeMetadataRequestIdOnDisk(reqIdRef.get());
+
+        ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, null).get(TIMEOUT);
+
+        assertCacheKeys(ignite.cache(DEFAULT_CACHE_NAME), CACHE_KEYS_RANGE);
+    }
+
+    /**
+     * @param newReqId Request ID that will be stored on all nodes.
+     * @throws Exception If failed.
+     */
+    private void changeMetadataRequestIdOnDisk(UUID newReqId) throws Exception {
+        for (Ignite grid : G.allGrids()) {
+            IgniteSnapshotManager snpMgr = ((IgniteEx)grid).context().cache().context().snapshotMgr();
+            String constId = grid.cluster().localNode().consistentId().toString();
+
+            SnapshotMetadata metadata = snpMgr.readSnapshotMetadata(SNAPSHOT_NAME, constId);
+            File smf = new File(snpMgr.snapshotLocalDir(SNAPSHOT_NAME), U.maskForFileName(constId) + SNAPSHOT_METAFILE_EXT);
+
+            try (OutputStream out = new BufferedOutputStream(new FileOutputStream(smf))) {
+                GridTestUtils.setFieldValue(metadata, "rqId", newReqId);
+
+                U.marshal(MarshallerUtils.jdkMarshaller(grid.name()), metadata, out);
+            }
+        }
+    }
+
+    /**
+     * Test for failures of different types of handlers.
+     *
+     * @throws Exception If fails.
+     */
+    @Test
+    public void testClusterSnapshotHandlerFailure() throws Exception {
+        String expMsg = "Test verification exception message.";
+
+        AtomicBoolean failCreateFlag = new AtomicBoolean(true);
+        AtomicBoolean failRestoreFlag = new AtomicBoolean(true);
+
+        handlers.add(new SnapshotHandler<Void>() {
+            @Override public SnapshotHandlerType type() {
+                return SnapshotHandlerType.CREATE;
+            }
+
+            @Override public Void invoke(SnapshotHandlerContext ctx) throws IgniteCheckedException {
+                if (failCreateFlag.get())
+                    throw new IgniteCheckedException(expMsg);
+
+                return null;
+            }
+        });
+
+        handlers.add(new SnapshotHandler<Void>() {
+            @Override public SnapshotHandlerType type() {
+                return SnapshotHandlerType.RESTORE;
+            }
+
+            @Override public Void invoke(SnapshotHandlerContext ctx) throws IgniteCheckedException {
+                if (failRestoreFlag.get())
+                    throw new IgniteCheckedException(expMsg);
+
+                return null;
+            }
+        });
+
+        IgniteEx ignite = startGridsWithCache(2, CACHE_KEYS_RANGE, valueBuilder(), dfltCacheCfg);
+
+        IgniteFuture<Void> fut = ignite.snapshot().createSnapshot(SNAPSHOT_NAME);
+
+        GridTestUtils.assertThrowsAnyCause(log, () -> fut.get(TIMEOUT), IgniteCheckedException.class, expMsg);
+
+        failCreateFlag.set(false);
+
+        ignite.snapshot().createSnapshot(SNAPSHOT_NAME).get(TIMEOUT);
+
+        ignite.cache(DEFAULT_CACHE_NAME).destroy();
+
+        awaitPartitionMapExchange();
+
+        IgniteFuture<Void> fut0 = ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, null);
+
+        GridTestUtils.assertThrowsAnyCause(log, () -> fut0.get(TIMEOUT), IgniteCheckedException.class, expMsg);
+
+        failRestoreFlag.set(false);
+
+        ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, null).get(TIMEOUT);
+
+        assertCacheKeys(ignite.cache(DEFAULT_CACHE_NAME), CACHE_KEYS_RANGE);
+    }
+
+    /**
+     * Test ensures that the snapshot operation is aborted if different handlers are loaded on different nodes.
+     *
+     * @throws Exception If fails.
+     */
+    @Test
+    public void testClusterSnapshotHandlerConfigurationMismatch() throws Exception {
+        SnapshotHandler<Void> defHnd = new SnapshotHandler<Void>() {
+            @Override public SnapshotHandlerType type() {
+                return SnapshotHandlerType.CREATE;
+            }
+
+            @Override public Void invoke(SnapshotHandlerContext ctx) {
+                return null;
+            }
+        };
+
+        handlers.add(defHnd);
+
+        startGridsWithCache(1, CACHE_KEYS_RANGE, valueBuilder(), dfltCacheCfg);
+
+        handlers.clear();
+
+        startGrid(1);
+
+        resetBaselineTopology();
+
+        // Case 1: handler is loaded on only one of the two nodes.
+        IgniteFuture<Void> fut0 = grid(0).snapshot().createSnapshot(SNAPSHOT_NAME);
+
+        UUID nodeId1 = grid(1).localNode().id();
+
+        GridTestUtils.assertThrowsAnyCause(log, () -> fut0.get(TIMEOUT), IgniteCheckedException.class,
+            "handler is missing on the remote node(s). The current operation will be aborted [missing=[" + nodeId1 + "]]");
+
+        stopGrid(1);
+
+        // Case 2: different handlers are loaded on different nodes.
+        handlers.add(new SnapshotHandler<Void>() {
+            @Override public SnapshotHandlerType type() {
+                return SnapshotHandlerType.CREATE;
+            }
+
+            @Nullable @Override public Void invoke(SnapshotHandlerContext ctx) {
+                return null;
+            }
+        });
+
+        startGrid(1);
+
+        IgniteFuture<Void> fut1 = grid(0).snapshot().createSnapshot(SNAPSHOT_NAME);
+
+        GridTestUtils.assertThrowsAnyCause(log, () -> fut1.get(TIMEOUT), IgniteCheckedException.class,
+            "Snapshot handlers configuration mismatch (number of local snapshot handlers differs from the remote one)");
+
+        stopGrid(1);
+
+        // Case 3: one handler is loaded on two nodes, the other only on one.
+        handlers.add(defHnd);
+
+        startGrid(1);
+
+        IgniteFuture<Void> fut2 = grid(0).snapshot().createSnapshot(SNAPSHOT_NAME);
+
+        GridTestUtils.assertThrowsAnyCause(log, () -> fut2.get(TIMEOUT), IgniteCheckedException.class,
+            "Snapshot handlers configuration mismatch (number of local snapshot handlers differs from the remote one)");
+
+        stopGrid(1);
+
+        // Make sure the operation was successful with the same configuration.
+        handlers.clear();
+        handlers.add(defHnd);
+
+        startGrid(1);
+
+        grid(1).snapshot().createSnapshot(SNAPSHOT_NAME).get(TIMEOUT);
+    }
+
+    /**
+     * Test ensures that the snapshot creation is aborted if node exits while the {@link
+     * SnapshotHandler#complete(String, Collection)} method is executed.
+     *
+     * @throws Exception If fails.
+     */
+    @Test
+    public void testCrdChangeDuringHandlerCompleteOnSnapshotCreate() throws Exception {
+        CountDownLatch latch = new CountDownLatch(1);
+
+        handlers.add(new SnapshotHandler<Void>() {
+            @Override public SnapshotHandlerType type() {
+                return SnapshotHandlerType.CREATE;
+            }
+
+            @Override public Void invoke(SnapshotHandlerContext ctx) {
+                return null;
+            }
+
+            @Override public void complete(String name, Collection<SnapshotHandlerResult<Void>> results)
+                throws Exception {
+                if (latch.getCount() == 1) {
+                    latch.countDown();
+
+                    Thread.sleep(Long.MAX_VALUE);
+                }
+            }
+        });
+
+        startGridsWithCache(2, CACHE_KEYS_RANGE, valueBuilder(), dfltCacheCfg);
+
+        IgniteFuture<Void> fut = grid(1).snapshot().createSnapshot(SNAPSHOT_NAME);
+
+        latch.await();
+
+        UUID crdNodeId = grid(0).localNode().id();
+
+        stopGrid(0, true);
+
+        GridTestUtils.assertThrowsAnyCause(log, () -> fut.get(TIMEOUT), ClusterTopologyCheckedException.class,
+            "Snapshot operation interrupted, because baseline node left the cluster: " + crdNodeId);
+
+        startGrid(0);
+        grid(0).snapshot().createSnapshot(SNAPSHOT_NAME);
+    }
+}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreBaseTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreBaseTest.java
index 18d02f5..9368ef3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreBaseTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreBaseTest.java
@@ -17,10 +17,21 @@
 
 package org.apache.ignite.internal.processors.cache.persistence.snapshot;
 
+import java.io.File;
+import java.util.Arrays;
 import java.util.function.Function;
+import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.cache.CacheGroupDescriptor;
+import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.internal.CU;
+import org.apache.ignite.testframework.GridTestUtils;
 
 /**
  * Snapshot restore test base.
@@ -72,6 +83,38 @@ public abstract class IgniteClusterSnapshotRestoreBaseTest extends AbstractSnaps
             assertEquals(valueBuilder().apply(i), cache.get(i));
     }
 
+    /**
+     * @param ccfg Cache configuration.
+     * @throws IgniteCheckedException if failed.
+     */
+    protected void ensureCacheAbsent(CacheConfiguration<?, ?> ccfg) throws IgniteCheckedException {
+        String cacheName = ccfg.getName();
+
+        for (Ignite ignite : G.allGrids()) {
+            GridKernalContext kctx = ((IgniteEx)ignite).context();
+
+            if (kctx.clientNode())
+                continue;
+
+            CacheGroupDescriptor desc = kctx.cache().cacheGroupDescriptors().get(CU.cacheId(cacheName));
+
+            assertNull("nodeId=" + kctx.localNodeId() + ", cache=" + cacheName, desc);
+
+            boolean success = GridTestUtils.waitForCondition(
+                () -> !kctx.cache().context().snapshotMgr().isRestoring(),
+                TIMEOUT);
+
+            assertTrue("The process has not finished on the node " + kctx.localNodeId(), success);
+
+            File dir = ((FilePageStoreManager)kctx.cache().context().pageStore()).cacheWorkDir(ccfg);
+
+            String errMsg = String.format("%s, dir=%s, exists=%b, files=%s",
+                ignite.name(), dir, dir.exists(), Arrays.toString(dir.list()));
+
+            assertTrue(errMsg, !dir.exists() || dir.list().length == 0);
+        }
+    }
+
     /** */
     protected class BinaryValueBuilder implements Function<Integer, Object> {
         /** Binary type name. */
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreSelfTest.java
index c59b797..526093e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreSelfTest.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.cache.persistence.snapshot;
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.OpenOption;
+import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Arrays;
 import java.util.Collections;
@@ -46,12 +47,10 @@ import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
 import org.apache.ignite.cluster.ClusterState;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.TestRecordingCommunicationSpi;
 import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
-import org.apache.ignite.internal.processors.cache.CacheGroupDescriptor;
 import org.apache.ignite.internal.processors.cache.DynamicCacheChangeBatch;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage;
 import org.apache.ignite.internal.processors.cache.persistence.file.FileIO;
@@ -60,8 +59,6 @@ import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStor
 import org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory;
 import org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType;
 import org.apache.ignite.internal.util.distributed.SingleNodeMessage;
-import org.apache.ignite.internal.util.typedef.G;
-import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteFuture;
 import org.apache.ignite.spi.IgniteSpiException;
@@ -75,9 +72,11 @@ import static org.apache.ignite.events.EventType.EVT_CLUSTER_SNAPSHOT_RESTORE_ST
 import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_DIR_PREFIX;
 import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.FILE_SUFFIX;
 import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.PART_FILE_PREFIX;
+import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.getPartitionFileName;
 import static org.apache.ignite.internal.processors.cache.persistence.snapshot.SnapshotRestoreProcess.TMP_CACHE_DIR_PREFIX;
 import static org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType.RESTORE_CACHE_GROUP_SNAPSHOT_PREPARE;
 import static org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType.RESTORE_CACHE_GROUP_SNAPSHOT_START;
+import static org.apache.ignite.testframework.GridTestUtils.assertThrowsAnyCause;
 import static org.apache.ignite.testframework.GridTestUtils.runAsync;
 
 /**
@@ -117,6 +116,29 @@ public class IgniteClusterSnapshotRestoreSelfTest extends IgniteClusterSnapshotR
         return valBuilder;
     }
 
+    /**
+     * Ensures that system partition verification task is invoked before restoring the snapshot.
+     *
+     * @throws Exception If failed.
+     */
+    @Test
+    public void testRestoreWithMissedPart() throws Exception {
+        IgniteEx ignite = startGridsWithSnapshot(2, CACHE_KEYS_RANGE);
+
+        Path part0 = U.searchFileRecursively(snp(ignite).snapshotLocalDir(SNAPSHOT_NAME).toPath(),
+            getPartitionFileName(0));
+
+        assertNotNull(part0);
+        assertTrue(part0.toString(), part0.toFile().exists());
+        assertTrue(part0.toFile().delete());
+
+        IgniteFuture<Void> fut = ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, null);
+        assertThrowsAnyCause(log, () -> fut.get(TIMEOUT), IgniteException.class,
+            "Snapshot data doesn't contain required cache group partition");
+
+        ensureCacheAbsent(dfltCacheCfg);
+    }
+
     /** @throws Exception If failed. */
     @Test
     public void testRestoreAllGroups() throws Exception {
@@ -746,36 +768,6 @@ public class IgniteClusterSnapshotRestoreSelfTest extends IgniteClusterSnapshotR
     }
 
     /**
-     * @param ccfg Cache configuration.
-     * @throws IgniteCheckedException if failed.
-     */
-    private void ensureCacheAbsent(CacheConfiguration<?, ?> ccfg) throws IgniteCheckedException {
-        String cacheName = ccfg.getName();
-
-        for (Ignite ignite : G.allGrids()) {
-            GridKernalContext kctx = ((IgniteEx)ignite).context();
-
-            if (kctx.clientNode())
-                continue;
-
-            CacheGroupDescriptor desc = kctx.cache().cacheGroupDescriptors().get(CU.cacheId(cacheName));
-
-            assertNull("nodeId=" + kctx.localNodeId() + ", cache=" + cacheName, desc);
-
-            GridTestUtils.waitForCondition(
-                () -> !kctx.cache().context().snapshotMgr().isRestoring(),
-                TIMEOUT);
-
-            File dir = ((FilePageStoreManager)kctx.cache().context().pageStore()).cacheWorkDir(ccfg);
-
-            String errMsg = String.format("%s, dir=%s, exists=%b, files=%s",
-                ignite.name(), dir, dir.exists(), Arrays.toString(dir.list()));
-
-            assertTrue(errMsg, !dir.exists() || dir.list().length == 0);
-        }
-    }
-
-    /**
      * @param spi Test communication spi.
      * @param restorePhase The type of distributed process on which communication is blocked.
      * @param grpName Cache group name.
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotSelfTest.java
index 64b1e16..28e1dea 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotSelfTest.java
@@ -44,6 +44,7 @@ import org.apache.ignite.IgniteException;
 import org.apache.ignite.Ignition;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.cluster.ClusterTopologyException;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteEx;
@@ -586,8 +587,8 @@ public class IgniteClusterSnapshotSelfTest extends AbstractSnapshotSelfTest {
 
         assertThrowsAnyCause(log,
             fut::get,
-            IgniteCheckedException.class,
-            "Execution of local snapshot tasks fails");
+            ClusterTopologyException.class,
+            "Snapshot operation interrupted, because baseline node left the cluster");
 
         waitForEvents(EVT_CLUSTER_SNAPSHOT_STARTED, EVT_CLUSTER_SNAPSHOT_FAILED);
 
@@ -640,8 +641,8 @@ public class IgniteClusterSnapshotSelfTest extends AbstractSnapshotSelfTest {
 
         assertThrowsAnyCause(log,
             () -> ignite.snapshot().createSnapshot(SNAPSHOT_NAME).get(),
-            IgniteCheckedException.class,
-            "Execution of local snapshot tasks fails");
+            ClusterTopologyException.class,
+            "Snapshot operation interrupted, because baseline node left the cluster");
 
         assertTrue("Snapshot directory must be empty: " + grid0Dir,
             !searchDirectoryRecursively(locSnpDir.toPath(), grid0Dir).isPresent());
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicWithPersistenceTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicWithPersistenceTestSuite.java
index 925f3f1..2b8dfe1 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicWithPersistenceTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicWithPersistenceTestSuite.java
@@ -41,6 +41,7 @@ import org.apache.ignite.internal.processors.cache.persistence.CheckpointReadLoc
 import org.apache.ignite.internal.processors.cache.persistence.CommonPoolStarvationCheckpointTest;
 import org.apache.ignite.internal.processors.cache.persistence.SingleNodePersistenceSslTest;
 import org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteClusterSnapshotCheckTest;
+import org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteClusterSnapshotHandlerTest;
 import org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteClusterSnapshotRestoreSelfTest;
 import org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteClusterSnapshotSelfTest;
 import org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotMXBeanTest;
@@ -103,6 +104,7 @@ import org.junit.runners.Suite;
     IgniteSnapshotWithMetastorageTest.class,
     IgniteSnapshotMXBeanTest.class,
     IgniteClusterSnapshotRestoreSelfTest.class,
+    IgniteClusterSnapshotHandlerTest.class,
 
     IgniteClusterIdTagTest.class,
     FullyConnectedComponentSearcherTest.class,