diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/stat/StatisticsConfigurationTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/stat/StatisticsConfigurationTest.java index eced0606697ef..ba042bf2581e5 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/stat/StatisticsConfigurationTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/stat/StatisticsConfigurationTest.java @@ -31,6 +31,7 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteInterruptedCheckedException; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemander; import org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager; import org.apache.ignite.internal.processors.query.stat.config.StatisticsObjectConfiguration; import org.apache.ignite.internal.processors.query.stat.messages.StatisticsObjectData; @@ -135,6 +136,11 @@ public static List parameters() { cleanPersistenceDir(); } + /** {@inheritDoc} */ + @Override protected long getPartitionMapExchangeTimeout() { + return super.getPartitionMapExchangeTimeout() * 3; + } + /** */ protected IgniteEx startGridAndChangeBaseline(int nodeIdx) throws Exception { IgniteEx ign = startGrid(nodeIdx); @@ -150,12 +156,35 @@ protected IgniteEx startGridAndChangeBaseline(int nodeIdx) throws Exception { } /** */ - protected void stopGridAndChangeBaseline(int nodeIdx) { + protected void stopGridAndChangeBaseline(int nodeIdx) throws Exception { stopGrid(nodeIdx); - if (persist) + if (persist) { F.first(G.allGrids()).cluster().setBaselineTopology(F.first(G.allGrids()).cluster().topologyVersion()); + // Wait for rebalancing to finish on all nodes after baseline change. + // setBaselineTopology triggers a full exchange with async rebalancing. + // awaitPartitionMapExchange checks ownerNodesCnt against readyAffinityVersion, + // but partition topology (MOVING) lags behind — causing infinite loop and timeout. + // We wait for the rebalance future to complete (blocking.get()) before proceeding. + for (Ignite grid : G.allGrids()) { + IgniteEx ign = (IgniteEx)grid; + + if (ign.cluster().localNode().isClient()) + continue; + + // Wait for ongoing rebalance to complete. + GridDhtPartitionDemander.RebalanceFuture rebFut = (GridDhtPartitionDemander.RebalanceFuture)ign + .cachex("SMALLnull").context().preloader().rebalanceFuture(); + + // If rebalance was cancelled (false), a new one may have started — retry. + while (!rebFut.isInitial() && !rebFut.get()) { + rebFut = (GridDhtPartitionDemander.RebalanceFuture)ign.cachex("SMALLnull") + .context().preloader().rebalanceFuture(); + } + } + } + try { awaitPartitionMapExchange(); }