Repository: ignite Updated Branches: refs/heads/ignite-2.5 bad3e400a -> 55c50a1c4
IGNITE-8066 AssertionError while trying to archive wal segment. - Fixes #3837. Signed-off-by: dpavlov <[email protected]> (cherry picked from commit 1fb2369) Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/55c50a1c Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/55c50a1c Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/55c50a1c Branch: refs/heads/ignite-2.5 Commit: 55c50a1c4309246e9cd254ed1f25b41b89f9a959 Parents: bad3e40 Author: Evgeny Stanilovskiy <[email protected]> Authored: Wed Apr 25 20:46:47 2018 +0300 Committer: dpavlov <[email protected]> Committed: Wed Apr 25 20:55:50 2018 +0300 ---------------------------------------------------------------------- .../GridCacheDatabaseSharedManager.java | 11 +++-- .../wal/IgniteWalHistoryReservationsTest.java | 49 ++++++++++++++++++-- 2 files changed, 52 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/55c50a1c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java index d5da199..42c7090 100755 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java @@ -747,6 +747,9 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan WALPointer restore = restoreMemory(status); + if (restore == null && status.endPtr != CheckpointStatus.NULL_PTR) + throw new StorageException("Restore wal pointer = " + restore + ", while status.endPtr = " + status.endPtr + "."); + // First, bring memory to the last consistent checkpoint state if needed. // This method should return a pointer to the last valid record in the WAL. @@ -767,7 +770,7 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan catch (StorageException e) { cctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); - throw new IgniteCheckedException(e); + throw e; } finally { checkpointReadUnlock(); @@ -1915,7 +1918,7 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan * @throws IgniteCheckedException If failed. * @throws StorageException In case I/O error occurred during operations with storage. */ - private WALPointer restoreMemory(CheckpointStatus status) throws IgniteCheckedException { + private @Nullable WALPointer restoreMemory(CheckpointStatus status) throws IgniteCheckedException { return restoreMemory(status, false, (PageMemoryEx)metaStorage.pageMemory()); } @@ -1926,7 +1929,7 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan * @throws IgniteCheckedException If failed. * @throws StorageException In case I/O error occurred during operations with storage. */ - private WALPointer restoreMemory(CheckpointStatus status, boolean storeOnly, + private @Nullable WALPointer restoreMemory(CheckpointStatus status, boolean storeOnly, PageMemoryEx storePageMem) throws IgniteCheckedException { assert !storeOnly || storePageMem != null; @@ -2079,7 +2082,7 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan if (status.needRestoreMemory()) { if (apply) - throw new IgniteCheckedException("Failed to restore memory state (checkpoint marker is present " + + throw new StorageException("Failed to restore memory state (checkpoint marker is present " + "on disk, but checkpoint record is missed in WAL) " + "[cpStatus=" + status + ", lastRead=" + lastRead + "]"); http://git-wip-us.apache.org/repos/asf/ignite/blob/55c50a1c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalHistoryReservationsTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalHistoryReservationsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalHistoryReservationsTest.java index 5ae16d2..e2c8bd1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalHistoryReservationsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalHistoryReservationsTest.java @@ -18,10 +18,10 @@ package org.apache.ignite.internal.processors.cache.persistence.db.wal; import java.util.Map; +import java.util.concurrent.Callable; import java.util.concurrent.locks.Lock; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteDataStreamer; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheWriteSynchronizationMode; @@ -31,12 +31,11 @@ import org.apache.ignite.configuration.DataRegionConfiguration; import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.WALMode; +import org.apache.ignite.failure.StopNodeFailureHandler; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition; -import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; import org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager; import org.apache.ignite.internal.util.lang.GridAbsPredicate; -import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; @@ -59,12 +58,15 @@ public class IgniteWalHistoryReservationsTest extends GridCommonAbstractTest { cfg.setConsistentId("NODE$" + gridName.charAt(gridName.length() - 1)); + cfg.setFailureHandler(new StopNodeFailureHandler()); + DataStorageConfiguration memCfg = new DataStorageConfiguration() .setDefaultDataRegionConfiguration( new DataRegionConfiguration() .setMaxSize(200 * 1024 * 1024) .setPersistenceEnabled(true)) - .setWalMode(WALMode.LOG_ONLY); + .setWalMode(WALMode.LOG_ONLY) + .setWalSegmentSize(512 * 1024); cfg.setDataStorageConfiguration(memCfg); @@ -355,6 +357,45 @@ public class IgniteWalHistoryReservationsTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + public void testWalHistoryPartiallyRemoved() throws Exception { + int entryCnt = 10_000; + + IgniteEx ig0 = (IgniteEx) startGrids(2); + + ig0.cluster().active(true); + + IgniteCache<Integer, Integer> cache = ig0.cache("cache1"); + + for (int k = 0; k < entryCnt; k++) + cache.put(k, k); + + GridTestUtils.runAsync(new Callable<Object>() { + @Override public Object call() throws Exception { + forceCheckpoint(); + + return null; + } + }); + + String nodeId0 = U.maskForFileName(ig0.localNode().consistentId().toString()); + + String walArchPath = ig0.configuration().getDataStorageConfiguration().getWalArchivePath(); + + stopAllGrids(); + + U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(), walArchPath + "/" + + nodeId0, false)); + + startGrid(0); + + Ignite ig1 = startGrid(1); + + ig1.cluster().active(true); + } + + /** + * @throws Exception If failed. + */ public void testNodeLeftDuringExchange() throws Exception { System.setProperty(IGNITE_PDS_WAL_REBALANCE_THRESHOLD, "0");
