From 2372a5139de2344d2664cc1b325fbd657184a553 Mon Sep 17 00:00:00 2001 From: Dmitry Werner Date: Mon, 13 Jul 2026 13:54:33 +0500 Subject: [PATCH 1/3] fix test --- .../cache/persistence/db/wal/IgniteWalRebalanceTest.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRebalanceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRebalanceTest.java index 61144f4159813..3987e30d17c4c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRebalanceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRebalanceTest.java @@ -338,6 +338,14 @@ public void testWithLocalWalChange() throws Exception { awaitPartitionMapExchange(); + // Wait for WAL rebalance to complete before modifying data to avoid race conditions. + for (Ignite ig : G.allGrids()) { + GridCachePreloader preloader = ((IgniteEx)ig).cachex(CACHE_NAME).context().group().preloader(); + + if (preloader.rebalanceFuture() != null) + preloader.rebalanceFuture().get(); + } + Set topVers = ((WalRebalanceCheckingCommunicationSpi)ignite.configuration().getCommunicationSpi()) .walRebalanceVersions(grpId); From 1725b9f012fdf4223be81da30476116d070856a7 Mon Sep 17 00:00:00 2001 From: Dmitry Werner Date: Mon, 13 Jul 2026 15:09:06 +0500 Subject: [PATCH 2/3] fix v2 --- .../db/wal/IgniteWalRebalanceTest.java | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRebalanceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRebalanceTest.java index 3987e30d17c4c..1f2cf60c01503 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRebalanceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRebalanceTest.java @@ -336,16 +336,34 @@ public void testWithLocalWalChange() throws Exception { // This node should rebalance data from other nodes and shouldn't have WAL history. Ignite ignite = startGrid(2); - awaitPartitionMapExchange(); + awaitPartitionMapExchange(true, true, null); - // Wait for WAL rebalance to complete before modifying data to avoid race conditions. + // Wait for WAL rebalance to complete. With ASYNC rebalance, rebalance completion triggers + // a minor exchange to update partition states (REBALANCING -> OWNED). We must wait for + // both rebalance AND the resulting minor exchange to finish, otherwise cache writes can + // race with the minor exchange and hit "Invalid version for inner update" errors. for (Ignite ig : G.allGrids()) { - GridCachePreloader preloader = ((IgniteEx)ig).cachex(CACHE_NAME).context().group().preloader(); + GridCachePreloader pld = ((IgniteEx)ig).cachex(CACHE_NAME).context().group().preloader(); - if (preloader.rebalanceFuture() != null) - preloader.rebalanceFuture().get(); + if (pld.rebalanceFuture() != null) + pld.rebalanceFuture().get(); } + // Wait for minor exchanges triggered by rebalance completion to finish on all nodes. + // Since minor exchanges are created asynchronously, we poll until no pending exchanges exist. + assertTrue(GridTestUtils.waitForCondition(() -> { + for (Ignite ig : G.allGrids()) { + List futs = ((IgniteEx)ig).context().cache().context().exchange().exchangeFutures(); + + for (GridDhtPartitionsExchangeFuture fut : futs) { + if (!fut.isDone()) + return false; + } + } + + return true; + }, getTestTimeout())); + Set topVers = ((WalRebalanceCheckingCommunicationSpi)ignite.configuration().getCommunicationSpi()) .walRebalanceVersions(grpId); From 4efd2fc39af0ec8b696300f48affb87ccc130401 Mon Sep 17 00:00:00 2001 From: Dmitry Werner Date: Mon, 13 Jul 2026 15:53:27 +0500 Subject: [PATCH 3/3] fix v3 --- .../cache/persistence/db/wal/IgniteWalRebalanceTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRebalanceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRebalanceTest.java index 1f2cf60c01503..b8bc509c7fea1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRebalanceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRebalanceTest.java @@ -384,6 +384,12 @@ else if (k % 3 == 1) // Spread removes across all partitions. stopGrid(1); + // Await exchange so that grid(2) finishes processing NODE_LEFT for the stopped + // nodes before grid(3) starts. Otherwise grid(2) may send near-atomic-update + // requests to already stopped nodes, causing CorruptedTreeException + // ("Invalid version for inner update"). + awaitPartitionMapExchange(); + // Start new node which should rebalance all data from node(2) without using WAL, // because node(2) doesn't have full history for rebalance. ignite = startGrid(3);