Vladsz83 commented on code in PR #11391:
URL: https://github.com/apache/ignite/pull/11391#discussion_r1718536553
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotChecker.java:
##########
@@ -536,19 +628,138 @@ private boolean hasExpiringEntries(
return rootIO.getCount(pageAddr) != 0;
}
+ /** Launches local partitions checking and waits for the result, handles
execution exceptions. */
+ public Map<PartitionKeyV2, PartitionHashRecordV2> checkPartitionsResult(
+ SnapshotMetadata meta,
+ File snpDir,
+ @Nullable Collection<String> groups,
+ boolean forCreation,
+ boolean checkParts,
+ boolean skipPartsHashes
+ ) {
+ try {
+ return checkPartitions(meta, snpDir, groups, forCreation,
checkParts, skipPartsHashes).get();
+ }
+ catch (Exception e) {
+ throw new IgniteException("Failed to get result of partitions
validation of snapshot '" + meta.snapshotName() + "'.", e);
+ }
+ }
+
+ /** Launches local partitions checking. */
+ public CompletableFuture<Map<PartitionKeyV2, PartitionHashRecordV2>>
checkPartitions(
+ SnapshotMetadata meta,
+ File snpDir,
+ @Nullable Collection<String> groups,
+ boolean forCreation,
+ boolean checkParts,
+ boolean skipPartsHashes
+ ) {
+ // Await in the default executor to avoid blocking the snapshot
executor if it has just one thread.
+ return CompletableFuture.supplyAsync(() -> {
+ if (!snpDir.exists())
+ throw new IllegalStateException("Snapshot directory doesn't
exists: " + snpDir);
+
+ ClusterNode locNode = kctx.cluster().get().localNode();
+
+ Set<Integer> grps = F.isEmpty(groups)
+ ? new HashSet<>(meta.partitions().keySet())
+ : groups.stream().map(CU::cacheId).collect(Collectors.toSet());
+
+ if (forCreation) {
+ grps = grps.stream().filter(grp -> grp ==
MetaStorage.METASTORAGE_CACHE_ID ||
+ CU.affinityNode(
+ locNode,
+
kctx.cache().cacheGroupDescriptor(grp).config().getNodeFilter()
+ )
+ ).collect(Collectors.toSet());
+ }
+
+ if (meta.dump())
+ return checkDumpFiles(snpDir, meta, grps,
locNode.consistentId(), checkParts, skipPartsHashes);
+
+ try {
+ return checkSnapshotFiles(snpDir, grps, meta, forCreation,
checkParts, skipPartsHashes);
+ }
+ catch (IgniteCheckedException e) {
+ throw new IgniteException("Failed to check partitions of
snapshot '" + meta.snapshotName() + "'.", e);
+ }
+ });
Review Comment:
Nope. The check funtions uses it, the same executor. If it configured with
just 1 thread (`setSnapshotThreadPoolSize(1)`), we'll freeze here. Tests like
`testChangeSnapshotTransferRateInRuntime()` would hang.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]