From fd6f2c23dc1fa6fad1032c809ca9b3217e1b4536 Mon Sep 17 00:00:00 2001 From: Maxim Pankovich Date: Wed, 18 Feb 2026 16:17:17 +0300 Subject: [PATCH 1/6] first --- .../org/apache/ignite/dump/DumpReader.java | 39 ++++++++--- .../dump/IgniteCacheDumpSelf2Test.java | 69 +++++++++++++++++++ 2 files changed, 98 insertions(+), 10 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java b/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java index 1443da99d3fc2..4d272c8e62f28 100644 --- a/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java +++ b/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java @@ -133,7 +133,8 @@ public DumpReader(DumpReaderConfiguration cfg, IgniteLogger log) { for (String node : e.getValue()) { for (int part : dump.partitions(node, grp)) { if (grps != null && !grps.get(grp).add(part)) { - log.info("Skip copy partition [node=" + node + ", grp=" + grp + ", part=" + part + ']'); + log.info("Skip copy partition [node=" + node + ", grpName=" + grpsCfgs.grpIdToName.get(grp) + + ", grp=" + grp + ", part=" + part + ']'); continue; } @@ -141,8 +142,8 @@ public DumpReader(DumpReaderConfiguration cfg, IgniteLogger log) { Runnable consumePart = () -> { if (skip.get()) { if (log.isDebugEnabled()) { - log.debug("Skip partition due to previous error [node=" + node + ", grp=" + grp + - ", part=" + part + ']'); + log.debug("Skip partition due to previous error [node=" + node + + ", grpName=" + grpsCfgs.grpIdToName.get(grp) + ", grp=" + grp + ", part=" + part + ']'); } return; @@ -150,8 +151,8 @@ public DumpReader(DumpReaderConfiguration cfg, IgniteLogger log) { try (DumpedPartitionIterator iter = dump.iterator(node, grp, part, grpsCfgs.cacheIds)) { if (log.isDebugEnabled()) { - log.debug("Consuming partition [node=" + node + ", grp=" + grp + - ", part=" + part + ']'); + log.debug("Consuming partition [node=" + node + ", grpName=" + grpsCfgs.grpIdToName.get(grp) + + ", grp=" + grp + ", part=" + part + ']'); } cnsmr.onPartition(grp, part, iter); @@ -159,8 +160,8 @@ public DumpReader(DumpReaderConfiguration cfg, IgniteLogger log) { catch (Exception ex) { skip.set(cfg.failFast()); - log.error("Error consuming partition [node=" + node + ", grp=" + grp + - ", part=" + part + ']', ex); + log.error("Error consuming partition [node=" + node + ", grpName=" + grpsCfgs.grpIdToName.get(grp) + + ", grp=" + grp + ", part=" + part + ']', ex); throw new IgniteException(ex); } @@ -365,9 +366,19 @@ private static GridKernalContext standaloneKernalContext(SnapshotFileTree sft, I private GroupsConfigs groupsConfigs(Dump dump) { Map> grpsToNodes = new HashMap<>(); List ccfgs = new ArrayList<>(); + Map grpIdToName = new HashMap<>(); Set grpIds = cfg.groupNames() != null - ? Arrays.stream(cfg.groupNames()).map(CU::cacheId).collect(Collectors.toSet()) + ? Arrays.stream(cfg.groupNames()) + .map(grpName -> { + int grpId = CU.cacheId(grpName); + + if (!grpIdToName.containsKey(grpId)) + grpIdToName.put(grpId, grpName); + + return grpId; + }) + .collect(Collectors.toSet()) : null; Set cacheIds = cfg.cacheNames() != null @@ -392,11 +403,14 @@ private GroupsConfigs groupsConfigs(Dump dump) { } grpsToNodes.get(grp).add(meta.folderName()); + + if (!grpIdToName.containsKey(grp) && !grpCaches.isEmpty()) + grpIdToName.put(grp, grpCaches.get(0).configuration().getGroupName()); } } // Optimize - skip whole cache if only one in group! - return new GroupsConfigs(grpsToNodes, ccfgs, cacheIds); + return new GroupsConfigs(grpsToNodes, ccfgs, cacheIds, grpIdToName); } /** */ @@ -410,11 +424,16 @@ private static class GroupsConfigs { /** Cache ids. */ public final Set cacheIds; + /** Mapping from group id to group name. */ + public final Map grpIdToName; + /** */ - public GroupsConfigs(Map> grpToNodes, Collection cacheCfgs, Set cacheIds) { + public GroupsConfigs(Map> grpToNodes, Collection cacheCfgs, Set cacheIds, + Map grpIdToName) { this.grpToNodes = grpToNodes; this.cacheCfgs = cacheCfgs; this.cacheIds = cacheIds; + this.grpIdToName = grpIdToName; } } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java index dfe11664e853b..0fbdc8fb353e3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java @@ -121,6 +121,7 @@ import static org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.SNAPSHOT_TRANSFER_RATE_DMS_KEY; import static org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.AbstractCacheDumpTest.CACHE_0; import static org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.AbstractCacheDumpTest.DMP_NAME; +import static org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.AbstractCacheDumpTest.GRP; import static org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.AbstractCacheDumpTest.KEYS_CNT; import static org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.AbstractCacheDumpTest.USER_FACTORY; import static org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.AbstractCacheDumpTest.dump; @@ -1219,6 +1220,74 @@ public void testReadEncrypted() throws Exception { IntStream.range(0, KEYS_CNT).forEach(i -> assertEquals((Integer)i, dumpEntries.get(i))); } + /** */ + @Test + public void testDumpReaderLogsGroupName() throws Exception { + String id = "test"; + ListeningTestLogger testLog = new ListeningTestLogger(log); + + // Listen for the error log that includes the group name + LogListener grpNameLsnr = LogListener.matches("Error consuming partition .*grpName=" + GRP + ".*") + .build(); + testLog.registerListener(grpNameLsnr); + + try { + IgniteEx ign0 = startGrid(getConfiguration(id) + .setConsistentId(id) + .setGridLogger(testLog)); // optional, not strictly needed + + ign0.cluster().state(ClusterState.ACTIVE); + + IgniteCache cache = ign0.createCache(new CacheConfiguration() + .setName(CACHE_0) + .setGroupName(GRP) + .setBackups(1) + .setAffinity(new RendezvousAffinityFunction().setPartitions(16)) + ); + + IntStream.range(0, KEYS_CNT).forEach(i -> cache.put(i, i)); + + ign0.snapshot().createDump(DMP_NAME, null).get(getTestTimeout()); + + // Consumer that throws an exception on the first partition + TestDumpConsumer cnsmr = new TestDumpConsumer() { + @Override public void onPartition(int grp, int part, Iterator data) { + throw new RuntimeException("Intentional exception to trigger error log"); + } + }; + + try { + new DumpReader( + new DumpReaderConfiguration( + DMP_NAME, + null, + ign0.configuration(), + cnsmr, + DFLT_THREAD_CNT, + DFLT_TIMEOUT, + true, // keepBinary + true, // keepRaw + false, // skipCopies (not needed for this test) + new String[]{GRP}, + null, // cacheNames + true, // failFast + null // encryptionSpi + ), + testLog + ).run(); + fail("Expected IgniteException"); + } + catch (IgniteException e) { + assertTrue("exeptionZZZZZZZZZZZZZZZZZZZZZz", true); + } + + assertTrue("Log with group name not found", grpNameLsnr.check()); + } + finally { + stopAllGrids(); + } + } + /** */ @Test public void testDumpRateLimiter() throws Exception { From 3a7ac9b60544411d1f7df5c9c44654b139dc217b Mon Sep 17 00:00:00 2001 From: Maxim Pankovich Date: Tue, 3 Mar 2026 06:48:49 +0300 Subject: [PATCH 2/6] tests and dumpreader --- .../org/apache/ignite/dump/DumpReader.java | 9 +- .../dump/IgniteCacheDumpSelf2Test.java | 129 ++++++++++++++++-- 2 files changed, 119 insertions(+), 19 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java b/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java index 4d272c8e62f28..e1d79317708d4 100644 --- a/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java +++ b/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java @@ -129,11 +129,12 @@ public DumpReader(DumpReaderConfiguration cfg, IgniteLogger log) { for (Map.Entry> e : grpsCfgs.grpToNodes.entrySet()) { int grp = e.getKey(); + String grpName = grpsCfgs.grpIdToName.get(grp); for (String node : e.getValue()) { for (int part : dump.partitions(node, grp)) { if (grps != null && !grps.get(grp).add(part)) { - log.info("Skip copy partition [node=" + node + ", grpName=" + grpsCfgs.grpIdToName.get(grp) + + log.info("Skip copy partition [node=" + node + ", grpName=" + grpName + ", grp=" + grp + ", part=" + part + ']'); continue; @@ -143,7 +144,7 @@ public DumpReader(DumpReaderConfiguration cfg, IgniteLogger log) { if (skip.get()) { if (log.isDebugEnabled()) { log.debug("Skip partition due to previous error [node=" + node + - ", grpName=" + grpsCfgs.grpIdToName.get(grp) + ", grp=" + grp + ", part=" + part + ']'); + ", grpName=" + grpName + ", grp=" + grp + ", part=" + part + ']'); } return; @@ -151,7 +152,7 @@ public DumpReader(DumpReaderConfiguration cfg, IgniteLogger log) { try (DumpedPartitionIterator iter = dump.iterator(node, grp, part, grpsCfgs.cacheIds)) { if (log.isDebugEnabled()) { - log.debug("Consuming partition [node=" + node + ", grpName=" + grpsCfgs.grpIdToName.get(grp) + + log.debug("Consuming partition [node=" + node + ", grpName=" + grpName + ", grp=" + grp + ", part=" + part + ']'); } @@ -160,7 +161,7 @@ public DumpReader(DumpReaderConfiguration cfg, IgniteLogger log) { catch (Exception ex) { skip.set(cfg.failFast()); - log.error("Error consuming partition [node=" + node + ", grpName=" + grpsCfgs.grpIdToName.get(grp) + + log.error("Error consuming partition [node=" + node + ", grpName=" + grpName + ", grp=" + grp + ", part=" + part + ']', ex); throw new IgniteException(ex); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java index 0fbdc8fb353e3..aceff5bc5eb0e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java @@ -1222,19 +1222,24 @@ public void testReadEncrypted() throws Exception { /** */ @Test - public void testDumpReaderLogsGroupName() throws Exception { + public void testDumpReaderDebugLogsGroupName() throws Exception { String id = "test"; + setLoggerDebugLevel(); ListeningTestLogger testLog = new ListeningTestLogger(log); - // Listen for the error log that includes the group name - LogListener grpNameLsnr = LogListener.matches("Error consuming partition .*grpName=" + GRP + ".*") + LogListener errLsnr = LogListener.matches("Error consuming partition") + .andMatches("grpName=" + GRP) .build(); - testLog.registerListener(grpNameLsnr); + LogListener cnsmLsnr = LogListener.matches("Consuming partition") + .andMatches("grpName=" + GRP) + .build(); + testLog.registerListener(errLsnr); + testLog.registerListener(cnsmLsnr); try { IgniteEx ign0 = startGrid(getConfiguration(id) .setConsistentId(id) - .setGridLogger(testLog)); // optional, not strictly needed + .setGridLogger(testLog)); ign0.cluster().state(ClusterState.ACTIVE); @@ -1242,17 +1247,16 @@ public void testDumpReaderLogsGroupName() throws Exception { .setName(CACHE_0) .setGroupName(GRP) .setBackups(1) - .setAffinity(new RendezvousAffinityFunction().setPartitions(16)) + .setAffinity(new RendezvousAffinityFunction().setPartitions(3)) ); IntStream.range(0, KEYS_CNT).forEach(i -> cache.put(i, i)); ign0.snapshot().createDump(DMP_NAME, null).get(getTestTimeout()); - // Consumer that throws an exception on the first partition TestDumpConsumer cnsmr = new TestDumpConsumer() { @Override public void onPartition(int grp, int part, Iterator data) { - throw new RuntimeException("Intentional exception to trigger error log"); + throw new RuntimeException("trigger error log"); } }; @@ -1265,13 +1269,13 @@ public void testDumpReaderLogsGroupName() throws Exception { cnsmr, DFLT_THREAD_CNT, DFLT_TIMEOUT, - true, // keepBinary - true, // keepRaw - false, // skipCopies (not needed for this test) + true, + true, + false, new String[]{GRP}, - null, // cacheNames - true, // failFast - null // encryptionSpi + null, + true, + null ), testLog ).run(); @@ -1281,10 +1285,105 @@ public void testDumpReaderLogsGroupName() throws Exception { assertTrue("exeptionZZZZZZZZZZZZZZZZZZZZZz", true); } - assertTrue("Log with group name not found", grpNameLsnr.check()); + assertTrue("Log with group name not found", errLsnr.check()); + assertTrue("Consuming with group name not found", cnsmLsnr.check()); + } + finally { + stopAllGrids(); + } + } + + /** */ + @Test + public void testDumpReaderSkipCopiesLogsGroupName() throws Exception { + int parts = 4; + + File snapshotPath = Files.createTempDirectory("snapshots").toFile(); + ListeningTestLogger testLog = new ListeningTestLogger(log); + + LogListener skipLsnr = LogListener.matches("Skip copy partition") + .times(parts) + .andMatches("grpName=" + GRP) + .build(); + testLog.registerListener(skipLsnr); + + try { + IgniteEx node0 = startGrid(getConfiguration("node0") + .setConsistentId("node0") + .setSnapshotPath(snapshotPath.getAbsolutePath()) + .setGridLogger(testLog)); + + IgniteEx node1 = startGrid(getConfiguration("node1") + .setConsistentId("node1") + .setSnapshotPath(snapshotPath.getAbsolutePath()) + .setGridLogger(testLog)); + + node0.cluster().state(ClusterState.ACTIVE); + node1.cluster().state(ClusterState.ACTIVE); + + CacheConfiguration ccfg = new CacheConfiguration() + .setName(DEFAULT_CACHE_NAME) + .setGroupName(GRP) + .setBackups(1) + .setAffinity(new RendezvousAffinityFunction().setPartitions(parts)); + + IgniteCache cache = node0.createCache(ccfg); + + IntStream.range(0, KEYS_CNT).forEach(i -> cache.put(i, i)); + + node0.snapshot().createDump(DMP_NAME, null).get(getTestTimeout()); + + DumpConsumer dummyConsumer = new DumpConsumer() { + @Override public void start() { + // No-op. + } + + @Override public void onMappings(Iterator mappings) { + // No-op. + } + + @Override public void onTypes(Iterator types) { + // No-op. + } + + @Override public void onCacheConfigs(Iterator caches) { + // No-op. + } + + @Override public void onPartition(int grpId, int partId, Iterator data) { + while (data.hasNext()) + data.next(); + } + + @Override public void stop() { + // No-op. + } + }; + + new DumpReader( + new DumpReaderConfiguration( + null, + new File(snapshotPath, DMP_NAME).getAbsolutePath(), + null, + dummyConsumer, + DFLT_THREAD_CNT, + DFLT_TIMEOUT, + false, + true, + true, + new String[]{GRP}, + null, + false, + null + ), + testLog + ).run(); + + assertTrue(skipLsnr.check()); } finally { stopAllGrids(); + U.delete(snapshotPath); } } From a7aea6f286ef4716856ad3d1fa1be96ecaef6966 Mon Sep 17 00:00:00 2001 From: Maxim Pankovich Date: Tue, 3 Mar 2026 08:17:31 +0300 Subject: [PATCH 3/6] fix tests --- .../dump/IgniteCacheDumpSelf2Test.java | 111 ++++++++++-------- 1 file changed, 64 insertions(+), 47 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java index aceff5bc5eb0e..50864df26c83c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java @@ -1228,26 +1228,26 @@ public void testDumpReaderDebugLogsGroupName() throws Exception { ListeningTestLogger testLog = new ListeningTestLogger(log); LogListener errLsnr = LogListener.matches("Error consuming partition") - .andMatches("grpName=" + GRP) - .build(); + .andMatches("grpName=" + GRP) + .build(); LogListener cnsmLsnr = LogListener.matches("Consuming partition") - .andMatches("grpName=" + GRP) - .build(); + .andMatches("grpName=" + GRP) + .build(); testLog.registerListener(errLsnr); testLog.registerListener(cnsmLsnr); try { IgniteEx ign0 = startGrid(getConfiguration(id) - .setConsistentId(id) - .setGridLogger(testLog)); + .setConsistentId(id) + .setGridLogger(testLog)); ign0.cluster().state(ClusterState.ACTIVE); IgniteCache cache = ign0.createCache(new CacheConfiguration() - .setName(CACHE_0) - .setGroupName(GRP) - .setBackups(1) - .setAffinity(new RendezvousAffinityFunction().setPartitions(3)) + .setName(CACHE_0) + .setGroupName(GRP) + .setBackups(1) + .setAffinity(new RendezvousAffinityFunction().setPartitions(3)) ); IntStream.range(0, KEYS_CNT).forEach(i -> cache.put(i, i)); @@ -1262,27 +1262,27 @@ public void testDumpReaderDebugLogsGroupName() throws Exception { try { new DumpReader( - new DumpReaderConfiguration( - DMP_NAME, - null, - ign0.configuration(), - cnsmr, - DFLT_THREAD_CNT, - DFLT_TIMEOUT, - true, - true, - false, - new String[]{GRP}, - null, - true, - null - ), - testLog + new DumpReaderConfiguration( + DMP_NAME, + null, + ign0.configuration(), + cnsmr, + DFLT_THREAD_CNT, + DFLT_TIMEOUT, + true, + true, + false, + new String[]{GRP}, + null, + false, + null + ), + testLog ).run(); fail("Expected IgniteException"); } - catch (IgniteException e) { - assertTrue("exeptionZZZZZZZZZZZZZZZZZZZZZz", true); + catch (IgniteException ignored) { + // No-op. } assertTrue("Log with group name not found", errLsnr.check()); @@ -1297,41 +1297,56 @@ public void testDumpReaderDebugLogsGroupName() throws Exception { @Test public void testDumpReaderSkipCopiesLogsGroupName() throws Exception { int parts = 4; + String dumpName0 = "dump0"; + String dumpName1 = "dump1"; + + File snapshotPath0 = Files.createTempDirectory("snapshots0").toFile(); + File snapshotPath1 = Files.createTempDirectory("snapshots1").toFile(); + File combinedDumpDir = Files.createTempDirectory("combined_dump").toFile(); - File snapshotPath = Files.createTempDirectory("snapshots").toFile(); ListeningTestLogger testLog = new ListeningTestLogger(log); LogListener skipLsnr = LogListener.matches("Skip copy partition") - .times(parts) - .andMatches("grpName=" + GRP) - .build(); + .times(parts) + .andMatches("grpName=" + GRP) + .build(); testLog.registerListener(skipLsnr); try { IgniteEx node0 = startGrid(getConfiguration("node0") - .setConsistentId("node0") - .setSnapshotPath(snapshotPath.getAbsolutePath()) - .setGridLogger(testLog)); + .setConsistentId("node0") + .setSnapshotPath(snapshotPath0.getAbsolutePath()) + .setGridLogger(testLog)); IgniteEx node1 = startGrid(getConfiguration("node1") - .setConsistentId("node1") - .setSnapshotPath(snapshotPath.getAbsolutePath()) - .setGridLogger(testLog)); + .setConsistentId("node1") + .setSnapshotPath(snapshotPath1.getAbsolutePath()) + .setGridLogger(testLog)); node0.cluster().state(ClusterState.ACTIVE); node1.cluster().state(ClusterState.ACTIVE); CacheConfiguration ccfg = new CacheConfiguration() - .setName(DEFAULT_CACHE_NAME) - .setGroupName(GRP) - .setBackups(1) - .setAffinity(new RendezvousAffinityFunction().setPartitions(parts)); + .setName(DEFAULT_CACHE_NAME) + .setGroupName(GRP) + .setBackups(1) + .setAffinity(new RendezvousAffinityFunction().setPartitions(parts)); IgniteCache cache = node0.createCache(ccfg); IntStream.range(0, KEYS_CNT).forEach(i -> cache.put(i, i)); - node0.snapshot().createDump(DMP_NAME, null).get(getTestTimeout()); + node0.snapshot().createDump(dumpName0, null).get(getTestTimeout()); + + Thread.sleep(100); + + node1.snapshot().createDump(dumpName1, null).get(getTestTimeout()); + + File dumpDir0 = new File(snapshotPath0, dumpName0); + File dumpDir1 = new File(snapshotPath1, dumpName1); + + U.copy(dumpDir0, combinedDumpDir, true); + U.copy(dumpDir1, combinedDumpDir, true); DumpConsumer dummyConsumer = new DumpConsumer() { @Override public void start() { @@ -1363,7 +1378,7 @@ public void testDumpReaderSkipCopiesLogsGroupName() throws Exception { new DumpReader( new DumpReaderConfiguration( null, - new File(snapshotPath, DMP_NAME).getAbsolutePath(), + combinedDumpDir.getAbsolutePath(), null, dummyConsumer, DFLT_THREAD_CNT, @@ -1373,17 +1388,19 @@ public void testDumpReaderSkipCopiesLogsGroupName() throws Exception { true, new String[]{GRP}, null, - false, + true, null ), - testLog + testLog ).run(); assertTrue(skipLsnr.check()); } finally { stopAllGrids(); - U.delete(snapshotPath); + U.delete(snapshotPath0); + U.delete(snapshotPath1); + U.delete(combinedDumpDir); } } From 7ab9076d13e802dc963c8270f27e5ec604b01707 Mon Sep 17 00:00:00 2001 From: Maxim Pankovich Date: Wed, 4 Mar 2026 21:17:52 +0300 Subject: [PATCH 4/6] review fixes 1 --- .../org/apache/ignite/dump/DumpReader.java | 13 ++- .../dump/IgniteCacheDumpSelf2Test.java | 102 ++++++++---------- 2 files changed, 49 insertions(+), 66 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java b/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java index e1d79317708d4..330253ffe86cc 100644 --- a/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java +++ b/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java @@ -134,8 +134,7 @@ public DumpReader(DumpReaderConfiguration cfg, IgniteLogger log) { for (String node : e.getValue()) { for (int part : dump.partitions(node, grp)) { if (grps != null && !grps.get(grp).add(part)) { - log.info("Skip copy partition [node=" + node + ", grpName=" + grpName + - ", grp=" + grp + ", part=" + part + ']'); + log.info("Skip copy partition [node=" + node + ", grp=" + grpName + ", part=" + part + ']'); continue; } @@ -143,8 +142,8 @@ public DumpReader(DumpReaderConfiguration cfg, IgniteLogger log) { Runnable consumePart = () -> { if (skip.get()) { if (log.isDebugEnabled()) { - log.debug("Skip partition due to previous error [node=" + node + - ", grpName=" + grpName + ", grp=" + grp + ", part=" + part + ']'); + log.debug("Skip partition due to previous error [node=" + node + ", grpName=" + grpName + + ", part=" + part + ']'); } return; @@ -153,7 +152,7 @@ public DumpReader(DumpReaderConfiguration cfg, IgniteLogger log) { try (DumpedPartitionIterator iter = dump.iterator(node, grp, part, grpsCfgs.cacheIds)) { if (log.isDebugEnabled()) { log.debug("Consuming partition [node=" + node + ", grpName=" + grpName + - ", grp=" + grp + ", part=" + part + ']'); + ", part=" + part + ']'); } cnsmr.onPartition(grp, part, iter); @@ -162,7 +161,7 @@ public DumpReader(DumpReaderConfiguration cfg, IgniteLogger log) { skip.set(cfg.failFast()); log.error("Error consuming partition [node=" + node + ", grpName=" + grpName + - ", grp=" + grp + ", part=" + part + ']', ex); + ", part=" + part + ']', ex); throw new IgniteException(ex); } @@ -405,7 +404,7 @@ private GroupsConfigs groupsConfigs(Dump dump) { grpsToNodes.get(grp).add(meta.folderName()); - if (!grpIdToName.containsKey(grp) && !grpCaches.isEmpty()) + if (!grpIdToName.containsKey(grp)) grpIdToName.put(grp, grpCaches.get(0).configuration().getGroupName()); } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java index 50864df26c83c..52e5912c2e3c4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java @@ -1224,73 +1224,59 @@ public void testReadEncrypted() throws Exception { @Test public void testDumpReaderDebugLogsGroupName() throws Exception { String id = "test"; + setLoggerDebugLevel(); + ListeningTestLogger testLog = new ListeningTestLogger(log); - LogListener errLsnr = LogListener.matches("Error consuming partition") - .andMatches("grpName=" + GRP) - .build(); - LogListener cnsmLsnr = LogListener.matches("Consuming partition") - .andMatches("grpName=" + GRP) - .build(); + LogListener errLsnr = LogListener.matches("Error consuming partition").andMatches("grp=" + GRP).build(); + LogListener cnsmLsnr = LogListener.matches("Consuming partition").andMatches("grp=" + GRP).build(); + testLog.registerListener(errLsnr); testLog.registerListener(cnsmLsnr); - try { - IgniteEx ign0 = startGrid(getConfiguration(id) - .setConsistentId(id) - .setGridLogger(testLog)); - - ign0.cluster().state(ClusterState.ACTIVE); + IgniteEx ign0 = startGrid(getConfiguration(id).setConsistentId(id).setGridLogger(testLog)); - IgniteCache cache = ign0.createCache(new CacheConfiguration() - .setName(CACHE_0) - .setGroupName(GRP) - .setBackups(1) - .setAffinity(new RendezvousAffinityFunction().setPartitions(3)) - ); + ign0.cluster().state(ClusterState.ACTIVE); - IntStream.range(0, KEYS_CNT).forEach(i -> cache.put(i, i)); + IgniteCache cache = ign0.createCache(new CacheConfiguration() + .setName(CACHE_0) + .setGroupName(GRP) + .setBackups(1) + .setAffinity(new RendezvousAffinityFunction().setPartitions(3)) + ); - ign0.snapshot().createDump(DMP_NAME, null).get(getTestTimeout()); + IntStream.range(0, KEYS_CNT).forEach(i -> cache.put(i, i)); - TestDumpConsumer cnsmr = new TestDumpConsumer() { - @Override public void onPartition(int grp, int part, Iterator data) { - throw new RuntimeException("trigger error log"); - } - }; + ign0.snapshot().createDump(DMP_NAME, null).get(getTestTimeout()); - try { - new DumpReader( - new DumpReaderConfiguration( - DMP_NAME, - null, - ign0.configuration(), - cnsmr, - DFLT_THREAD_CNT, - DFLT_TIMEOUT, - true, - true, - false, - new String[]{GRP}, - null, - false, - null - ), - testLog - ).run(); - fail("Expected IgniteException"); - } - catch (IgniteException ignored) { - // No-op. + TestDumpConsumer cnsmr = new TestDumpConsumer() { + @Override public void onPartition(int grp, int part, Iterator data) { + throw new RuntimeException("trigger error log"); } + }; - assertTrue("Log with group name not found", errLsnr.check()); - assertTrue("Consuming with group name not found", cnsmLsnr.check()); - } - finally { - stopAllGrids(); - } + assertThrows(null, () -> new DumpReader( + new DumpReaderConfiguration( + DMP_NAME, + null, + ign0.configuration(), + cnsmr, + DFLT_THREAD_CNT, + DFLT_TIMEOUT, + true, + true, + false, + new String[]{GRP}, + null, + false, + null + ), + testLog + ).run(), RuntimeException.class, "trigger error log"); + + assertTrue("Log with group name not found", errLsnr.check()); + assertTrue("Consuming with group name not found", cnsmLsnr.check()); } /** */ @@ -1308,8 +1294,9 @@ public void testDumpReaderSkipCopiesLogsGroupName() throws Exception { LogListener skipLsnr = LogListener.matches("Skip copy partition") .times(parts) - .andMatches("grpName=" + GRP) + .andMatches("grp=" + GRP) .build(); + testLog.registerListener(skipLsnr); try { @@ -1324,7 +1311,6 @@ public void testDumpReaderSkipCopiesLogsGroupName() throws Exception { .setGridLogger(testLog)); node0.cluster().state(ClusterState.ACTIVE); - node1.cluster().state(ClusterState.ACTIVE); CacheConfiguration ccfg = new CacheConfiguration() .setName(DEFAULT_CACHE_NAME) @@ -1366,8 +1352,7 @@ public void testDumpReaderSkipCopiesLogsGroupName() throws Exception { } @Override public void onPartition(int grpId, int partId, Iterator data) { - while (data.hasNext()) - data.next(); + // No-op. } @Override public void stop() { @@ -1397,7 +1382,6 @@ public void testDumpReaderSkipCopiesLogsGroupName() throws Exception { assertTrue(skipLsnr.check()); } finally { - stopAllGrids(); U.delete(snapshotPath0); U.delete(snapshotPath1); U.delete(combinedDumpDir); From eb1830b39aff2231b2633a53eb8b8af13cdc5122 Mon Sep 17 00:00:00 2001 From: Maxim Pankovich Date: Thu, 5 Mar 2026 13:28:53 +0300 Subject: [PATCH 5/6] new test and fixes and refactoring --- .../org/apache/ignite/dump/DumpReader.java | 6 +-- .../dump/IgniteCacheDumpSelf2Test.java | 47 ++++++++++++------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java b/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java index 330253ffe86cc..102f5294037cb 100644 --- a/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java +++ b/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java @@ -142,7 +142,7 @@ public DumpReader(DumpReaderConfiguration cfg, IgniteLogger log) { Runnable consumePart = () -> { if (skip.get()) { if (log.isDebugEnabled()) { - log.debug("Skip partition due to previous error [node=" + node + ", grpName=" + grpName + + log.debug("Skip partition due to previous error [node=" + node + ", grp=" + grpName + ", part=" + part + ']'); } @@ -151,7 +151,7 @@ public DumpReader(DumpReaderConfiguration cfg, IgniteLogger log) { try (DumpedPartitionIterator iter = dump.iterator(node, grp, part, grpsCfgs.cacheIds)) { if (log.isDebugEnabled()) { - log.debug("Consuming partition [node=" + node + ", grpName=" + grpName + + log.debug("Consuming partition [node=" + node + ", grp=" + grpName + ", part=" + part + ']'); } @@ -160,7 +160,7 @@ public DumpReader(DumpReaderConfiguration cfg, IgniteLogger log) { catch (Exception ex) { skip.set(cfg.failFast()); - log.error("Error consuming partition [node=" + node + ", grpName=" + grpName + + log.error("Error consuming partition [node=" + node + ", grp=" + grpName + ", part=" + part + ']', ex); throw new IgniteException(ex); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java index 52e5912c2e3c4..034377f73dfdc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java @@ -1221,8 +1221,7 @@ public void testReadEncrypted() throws Exception { } /** */ - @Test - public void testDumpReaderDebugLogsGroupName() throws Exception { + private void CheckDumpReaderDebugLogsGroupName(String[] grpNames) throws Exception { String id = "test"; setLoggerDebugLevel(); @@ -1257,28 +1256,40 @@ public void testDumpReaderDebugLogsGroupName() throws Exception { }; assertThrows(null, () -> new DumpReader( - new DumpReaderConfiguration( - DMP_NAME, - null, - ign0.configuration(), - cnsmr, - DFLT_THREAD_CNT, - DFLT_TIMEOUT, - true, - true, - false, - new String[]{GRP}, - null, - false, - null - ), - testLog + new DumpReaderConfiguration( + DMP_NAME, + null, + ign0.configuration(), + cnsmr, + DFLT_THREAD_CNT, + DFLT_TIMEOUT, + true, + true, + false, + grpNames, + null, + false, + null + ), + testLog ).run(), RuntimeException.class, "trigger error log"); assertTrue("Log with group name not found", errLsnr.check()); assertTrue("Consuming with group name not found", cnsmLsnr.check()); } + /** */ + @Test + public void testDumpReaderDebugLogsGroupName() throws Exception { + CheckDumpReaderDebugLogsGroupName(new String[]{GRP}); + } + + /** */ + @Test + public void testDumpReaderDebugLogsGroupNameNull() throws Exception { + CheckDumpReaderDebugLogsGroupName(null); + } + /** */ @Test public void testDumpReaderSkipCopiesLogsGroupName() throws Exception { From 4606651d9e21dcfd0c8121d57e705bd1a0ae5343 Mon Sep 17 00:00:00 2001 From: Maxim Pankovich Date: Thu, 5 Mar 2026 19:14:04 +0300 Subject: [PATCH 6/6] review fixes 3 --- .../org/apache/ignite/dump/DumpReader.java | 8 +- .../dump/IgniteCacheDumpSelf2Test.java | 212 +++++++++--------- 2 files changed, 112 insertions(+), 108 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java b/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java index 102f5294037cb..868235683636c 100644 --- a/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java +++ b/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java @@ -428,8 +428,12 @@ private static class GroupsConfigs { public final Map grpIdToName; /** */ - public GroupsConfigs(Map> grpToNodes, Collection cacheCfgs, Set cacheIds, - Map grpIdToName) { + public GroupsConfigs( + Map> grpToNodes, + Collection cacheCfgs, + Set cacheIds, + Map grpIdToName + ) { this.grpToNodes = grpToNodes; this.cacheCfgs = cacheCfgs; this.cacheIds = cacheIds; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java index 034377f73dfdc..662ecb00e513c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java @@ -1221,73 +1221,92 @@ public void testReadEncrypted() throws Exception { } /** */ - private void CheckDumpReaderDebugLogsGroupName(String[] grpNames) throws Exception { - String id = "test"; + @Test + public void testDumpRateLimiter() throws Exception { + try (IgniteEx ign = startGrid(0)) { + ign.cluster().state(ClusterState.ACTIVE); - setLoggerDebugLevel(); + byte[] val = new byte[(int)U.KB]; + ThreadLocalRandom.current().nextBytes(val); - ListeningTestLogger testLog = new ListeningTestLogger(log); + int keysCnt = 10; - LogListener errLsnr = LogListener.matches("Error consuming partition").andMatches("grp=" + GRP).build(); - LogListener cnsmLsnr = LogListener.matches("Consuming partition").andMatches("grp=" + GRP).build(); + for (int i = 0; i < keysCnt; i++) + ign.getOrCreateCache(DEFAULT_CACHE_NAME).put(i, val); - testLog.registerListener(errLsnr); - testLog.registerListener(cnsmLsnr); + ign.context().distributedConfiguration() + .property(SNAPSHOT_TRANSFER_RATE_DMS_KEY) + .propagate(U.KB); - IgniteEx ign0 = startGrid(getConfiguration(id).setConsistentId(id).setGridLogger(testLog)); + IgniteFuture fut = ign.snapshot().createDump(DMP_NAME, null); - ign0.cluster().state(ClusterState.ACTIVE); + IgniteSnapshotManager snpMgr = ign.context().cache().context().snapshotMgr(); - IgniteCache cache = ign0.createCache(new CacheConfiguration() - .setName(CACHE_0) - .setGroupName(GRP) - .setBackups(1) - .setAffinity(new RendezvousAffinityFunction().setPartitions(3)) - ); + assertTrue(GridTestUtils.waitForCondition(() -> + snpMgr.currentSnapshotTask(CreateDumpFutureTask.class) != null, 10_000, 10)); - IntStream.range(0, KEYS_CNT).forEach(i -> cache.put(i, i)); + CreateDumpFutureTask task = snpMgr.currentSnapshotTask(CreateDumpFutureTask.class); - ign0.snapshot().createDump(DMP_NAME, null).get(getTestTimeout()); + List processedVals = new ArrayList<>(); - TestDumpConsumer cnsmr = new TestDumpConsumer() { - @Override public void onPartition(int grp, int part, Iterator data) { - throw new RuntimeException("trigger error log"); - } - }; + assertTrue(GridTestUtils.waitForCondition(() -> { + processedVals.add(task.processedSize()); - assertThrows(null, () -> new DumpReader( - new DumpReaderConfiguration( + return fut.isDone(); + }, getTestTimeout(), 100)); + + assertTrue("Expected distinct values: " + processedVals, + processedVals.stream().mapToLong(v -> v).distinct().count() >= keysCnt); + + assertTrue("Expected sorted values: " + processedVals, + F.isSorted(processedVals.stream().mapToLong(v -> v).toArray())); + } + } + + /** */ + @Test + public void testConfigOnlySnapshotThrows() throws Exception { + try (IgniteEx ign = startGrid(0)) { + ign.cluster().state(ClusterState.ACTIVE); + + IgniteCache c = ign.createCache(DEFAULT_CACHE_NAME); + + IntStream.range(0, 10).forEach(i -> c.put(i, i)); + + IgniteSnapshotManager snpMgr = ign.context().cache().context().snapshotMgr(); + + assertThrows( + null, + () -> { + snpMgr.createSnapshot( DMP_NAME, null, - ign0.configuration(), - cnsmr, - DFLT_THREAD_CNT, - DFLT_TIMEOUT, - true, - true, - false, - grpNames, null, false, - null - ), - testLog - ).run(), RuntimeException.class, "trigger error log"); - - assertTrue("Log with group name not found", errLsnr.check()); - assertTrue("Consuming with group name not found", cnsmLsnr.check()); + false, + false, + false, + false, + false, + true + ); + }, + IgniteException.class, + "Config only supported only for dump" + ); + } } /** */ @Test public void testDumpReaderDebugLogsGroupName() throws Exception { - CheckDumpReaderDebugLogsGroupName(new String[]{GRP}); + checkDumpReaderDebugLogsGroupName(new String[]{GRP}); } /** */ @Test - public void testDumpReaderDebugLogsGroupNameNull() throws Exception { - CheckDumpReaderDebugLogsGroupName(null); + public void testDumpReaderDebugLogsNullableGroupName() throws Exception { + checkDumpReaderDebugLogsGroupName(null); } /** */ @@ -1335,7 +1354,7 @@ public void testDumpReaderSkipCopiesLogsGroupName() throws Exception { node0.snapshot().createDump(dumpName0, null).get(getTestTimeout()); - Thread.sleep(100); + U.sleep(100); node1.snapshot().createDump(dumpName1, null).get(getTestTimeout()); @@ -1400,80 +1419,61 @@ public void testDumpReaderSkipCopiesLogsGroupName() throws Exception { } /** */ - @Test - public void testDumpRateLimiter() throws Exception { - try (IgniteEx ign = startGrid(0)) { - ign.cluster().state(ClusterState.ACTIVE); - - byte[] val = new byte[(int)U.KB]; - ThreadLocalRandom.current().nextBytes(val); - - int keysCnt = 10; - - for (int i = 0; i < keysCnt; i++) - ign.getOrCreateCache(DEFAULT_CACHE_NAME).put(i, val); - - ign.context().distributedConfiguration() - .property(SNAPSHOT_TRANSFER_RATE_DMS_KEY) - .propagate(U.KB); - - IgniteFuture fut = ign.snapshot().createDump(DMP_NAME, null); - - IgniteSnapshotManager snpMgr = ign.context().cache().context().snapshotMgr(); - - assertTrue(GridTestUtils.waitForCondition(() -> - snpMgr.currentSnapshotTask(CreateDumpFutureTask.class) != null, 10_000, 10)); + private void checkDumpReaderDebugLogsGroupName(String[] grpNames) throws Exception { + String id = "test"; - CreateDumpFutureTask task = snpMgr.currentSnapshotTask(CreateDumpFutureTask.class); + setLoggerDebugLevel(); - List processedVals = new ArrayList<>(); + ListeningTestLogger testLog = new ListeningTestLogger(log); - assertTrue(GridTestUtils.waitForCondition(() -> { - processedVals.add(task.processedSize()); + LogListener errLsnr = LogListener.matches("Error consuming partition").andMatches("grp=" + GRP).build(); + LogListener cnsmLsnr = LogListener.matches("Consuming partition").andMatches("grp=" + GRP).build(); - return fut.isDone(); - }, getTestTimeout(), 100)); + testLog.registerListener(errLsnr); + testLog.registerListener(cnsmLsnr); - assertTrue("Expected distinct values: " + processedVals, - processedVals.stream().mapToLong(v -> v).distinct().count() >= keysCnt); + IgniteEx ign = startGrid(getConfiguration(id).setConsistentId(id).setGridLogger(testLog)); - assertTrue("Expected sorted values: " + processedVals, - F.isSorted(processedVals.stream().mapToLong(v -> v).toArray())); - } - } + ign.cluster().state(ClusterState.ACTIVE); - /** */ - @Test - public void testConfigOnlySnapshotThrows() throws Exception { - try (IgniteEx ign = startGrid(0)) { - ign.cluster().state(ClusterState.ACTIVE); + IgniteCache cache = ign.createCache(new CacheConfiguration() + .setName(CACHE_0) + .setGroupName(GRP) + .setBackups(1) + .setAffinity(new RendezvousAffinityFunction().setPartitions(3)) + ); - IgniteCache c = ign.createCache(DEFAULT_CACHE_NAME); + IntStream.range(0, KEYS_CNT).forEach(i -> cache.put(i, i)); - IntStream.range(0, 10).forEach(i -> c.put(i, i)); + ign.snapshot().createDump(DMP_NAME, null).get(getTestTimeout()); - IgniteSnapshotManager snpMgr = ign.context().cache().context().snapshotMgr(); + TestDumpConsumer cnsmr = new TestDumpConsumer() { + @Override public void onPartition(int grp, int part, Iterator data) { + throw new RuntimeException("trigger error log"); + } + }; - assertThrows( + assertThrows(null, () -> new DumpReader( + new DumpReaderConfiguration( + DMP_NAME, null, - () -> { - snpMgr.createSnapshot( - DMP_NAME, - null, - null, - false, - false, - false, - false, - false, - false, - true - ); - }, - IgniteException.class, - "Config only supported only for dump" - ); - } + ign.configuration(), + cnsmr, + DFLT_THREAD_CNT, + DFLT_TIMEOUT, + true, + true, + false, + grpNames, + null, + false, + null + ), + testLog + ).run(), RuntimeException.class, "trigger error log"); + + assertTrue("Log with group name not found", errLsnr.check()); + assertTrue("Consuming with group name not found", cnsmLsnr.check()); } /** */