This is an automated email from the ASF dual-hosted git repository.
nizhikov 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 6e6871673c2 IGNITE-28846 Fix dump creation when several disk and
absolute path used (#13317)
6e6871673c2 is described below
commit 6e6871673c2a9a09b7e88044fe9d86ffa652e1fd
Author: Nikolay <[email protected]>
AuthorDate: Fri Jul 3 10:57:25 2026 +0300
IGNITE-28846 Fix dump creation when several disk and absolute path used
(#13317)
---
.../snapshot/dump/CreateDumpFutureTask.java | 8 +-
.../dump/IgniteCacheDumpSeveralDiskTest.java | 125 +++++++++++++++++++++
.../testsuites/IgniteSnapshotTestSuite4.java | 2 +
3 files changed, 133 insertions(+), 2 deletions(-)
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/CreateDumpFutureTask.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/CreateDumpFutureTask.java
index 674b664f169..39186910d4e 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/CreateDumpFutureTask.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/CreateDumpFutureTask.java
@@ -72,6 +72,8 @@ import org.apache.ignite.internal.util.BasicRateLimiter;
import org.apache.ignite.internal.util.GridConcurrentHashSet;
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.lang.GridCloseableIterator;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.U;
import org.jetbrains.annotations.Nullable;
import static
org.apache.ignite.internal.pagemem.PageIdAllocator.INDEX_PARTITION;
@@ -225,8 +227,10 @@ public class CreateDumpFutureTask extends
AbstractCreateSnapshotFutureTask imple
int grp = e.getKey();
for (File grpDumpDir :
sft.cacheStorages(cctx.cache().cacheGroup(grp).config())) {
- if (!grpDumpDir.mkdirs())
- throw new IgniteCheckedException("Dump directory can't be
created: " + grpDumpDir);
+ U.ensureDirectory(grpDumpDir, "directory for dump cache
group", log);
+
+ if (!F.isEmpty(grpDumpDir.listFiles()))
+ throw new IgniteCheckedException("Dump directory not
empty: " + grpDumpDir);
}
CacheGroupContext gctx = cctx.cache().cacheGroup(grp);
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSeveralDiskTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSeveralDiskTest.java
new file mode 100644
index 00000000000..9eb4055b8e0
--- /dev/null
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSeveralDiskTest.java
@@ -0,0 +1,125 @@
+/*
+ * 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.dump;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.stream.IntStream;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+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.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.jetbrains.annotations.NotNull;
+import org.junit.Test;
+
+/** */
+public class IgniteCacheDumpSeveralDiskTest extends GridCommonAbstractTest {
+ /** */
+ public static final String NVME_1 = "nvme1";
+
+ /** */
+ public static final String NVME_2 = "nvme2";
+
+ /** */
+ public static final String NVME_4 = "nvme4";
+
+ /** */
+ public static final String NVME_5 = "nvme5";
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ cleanPersistenceDir();
+
+ U.delete(new File(U.defaultWorkDirectory()));
+
+ assertTrue(U.mkdirs(new File(path(NVME_5))));
+
+ IgniteEx srv = startGrid(0);
+
+ srv.cluster().state(ClusterState.ACTIVE);
+
+ IgniteCache<Object, Object> c = srv.createCache(new
CacheConfiguration<>("cache")
+ .setStoragePaths(path(NVME_1), path(NVME_2), path(NVME_4))
+ .setAffinity(new RendezvousAffinityFunction().setPartitions(3)));
+
+ IntStream.range(0, 10).forEach(i -> c.put(i, i));
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String
igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+ DataStorageConfiguration dsCfg = new DataStorageConfiguration();
+
+ dsCfg
+ .setStoragePath(path(NVME_1))
+ .setExtraStoragePaths(path(NVME_2), path(NVME_4))
+ .setDefaultDataRegionConfiguration(new
DataRegionConfiguration().setPersistenceEnabled(true));
+
+ return
cfg.setDataStorageConfiguration(dsCfg).setSnapshotPath("/dev/null");
+ }
+
+ /** */
+ @Test
+ public void testSeveralDisksDump() throws Exception {
+ createSnapshot(true);
+ }
+
+ /** */
+ @Test
+ public void testSeveralDisksSnapshot() throws Exception {
+ createSnapshot(false);
+ }
+
+ /** */
+ private void createSnapshot(boolean dump) throws Exception {
+ String name = dump ? "dump" : "snapshot";
+ String snpPath = path("nvme5/snapshot");
+ Collection<String> cacheGrpNames = null;
+ boolean incremental = false;
+ boolean onlyPrimary = true;
+ boolean compress = false;
+ boolean encrypt = false;
+
+ grid(0).context().cache().context().snapshotMgr().createSnapshot(
+ name,
+ snpPath,
+ cacheGrpNames,
+ incremental,
+ onlyPrimary,
+ dump,
+ compress,
+ encrypt,
+ false,
+ false
+ ).get();
+ }
+
+ /** */
+ private static @NotNull String path(String path) throws
IgniteCheckedException {
+ return U.defaultWorkDirectory() + "/" + path;
+ }
+}
diff --git
a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSnapshotTestSuite4.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSnapshotTestSuite4.java
index 633db0b11c8..86131e32f20 100644
---
a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSnapshotTestSuite4.java
+++
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSnapshotTestSuite4.java
@@ -25,6 +25,7 @@ import
org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.Ign
import
org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.IgniteCacheDumpFilterTest;
import
org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.IgniteCacheDumpSelf2Test;
import
org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.IgniteCacheDumpSelfTest;
+import
org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.IgniteCacheDumpSeveralDiskTest;
import
org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.IgniteConcurrentCacheDumpTest;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.DynamicSuite;
@@ -50,5 +51,6 @@ public class IgniteSnapshotTestSuite4 {
GridTestUtils.addTestIfNeeded(suite,
IgniteConcurrentCacheDumpTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, IgniteCacheDumpFilterTest.class,
ignoredTests);
GridTestUtils.addTestIfNeeded(suite, BufferedFileIOTest.class,
ignoredTests);
+ GridTestUtils.addTestIfNeeded(suite,
IgniteCacheDumpSeveralDiskTest.class, ignoredTests);
}
}