/** * Correct delete archived wal files. */ @Test public void testCorrectDeletedArchivedWalFiles() throws Exception { //given: configured grid with setted max wal archive size long maxWalArchiveSize = 2 * 1024 * 1024; Ignite ignite = startGrid(dbCfg -> { dbCfg.setMaxWalArchiveSize(maxWalArchiveSize); }); GridCacheDatabaseSharedManager dbMgr = gridDatabase(ignite); long allowedThresholdWalArchiveSize = maxWalArchiveSize / 2; IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(cacheConfiguration()); //when: put to cache more than 2 MB for (int i = 0; i < 500; i++) cache.put(i, i); forceCheckpoint(); //then: total archive size less than half of maxWalArchiveSize(by current logic) IgniteWriteAheadLogManager wal = wal(ignite); FileDescriptor[] files = (FileDescriptor[])U.findNonPublicMethod(wal.getClass(), "walArchiveFiles").invoke(wal); Long totalSize = Stream.of(files) .map(desc -> desc.file().length()) .reduce(0L, Long::sum); assertTrue(files.length >= 1); assertTrue(totalSize <= allowedThresholdWalArchiveSize); assertFalse(Stream.of(files).anyMatch(desc -> desc.file().getName().endsWith("00001.wal"))); CheckpointHistory hist = dbMgr.checkpointHistory(); assertTrue(!hist.checkpoints().isEmpty()); }
/** * Correct delete checkpoint history from memory depends on IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE. WAL files * doesn't delete because deleting was disabled. */ @Test public void testCorrectDeletedCheckpointHistoryButKeepWalFiles() throws Exception { System.setProperty(IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE, "2"); //given: configured grid with disabled WAL removing. Ignite ignite = startGrid(dbCfg -> { dbCfg.setMaxWalArchiveSize(Long.MAX_VALUE); }); GridCacheDatabaseSharedManager dbMgr = gridDatabase(ignite); IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(cacheConfiguration()); //when: put to cache for (int i = 0; i < 500; i++) { cache.put(i, i); if (i % 10 == 0) forceCheckpoint(); } forceCheckpoint(); //then: WAL files was not deleted but some of checkpoint history was deleted. IgniteWriteAheadLogManager wal = wal(ignite); FileDescriptor[] files = (FileDescriptor[])U.findNonPublicMethod(wal.getClass(), "walArchiveFiles").invoke(wal); boolean hasFirstSegment = Stream.of(files) .anyMatch(desc -> desc.file().getName().endsWith("0001.wal")); assertTrue(hasFirstSegment); CheckpointHistory hist = dbMgr.checkpointHistory(); assertTrue(hist.checkpoints().size() == 2); }
/** * History size parameters consistency check. Should be set just one of wal history size or max wal archive size. */ @Test public void testGridDoesNotStart_BecauseBothWalHistorySizeAndMaxWalArchiveSizeUsed() throws Exception { //given: wal history size and max wal archive size are both set. IgniteConfiguration configuration = getConfiguration(getTestIgniteInstanceName()); DataStorageConfiguration dbCfg = new DataStorageConfiguration(); dbCfg.setWalHistorySize(12); dbCfg.setMaxWalArchiveSize(9); configuration.setDataStorageConfiguration(dbCfg); try { //when: start grid. startGrid(getTestIgniteInstanceName(), configuration); fail("Should be fail because both wal history size and max wal archive size was used"); } catch (IgniteException e) { //then: exception is occurrence because should be set just one parameters. assertTrue(findSourceMessage(e).startsWith("Should be used only one of wal history size or max wal archive size")); } }
/** * Checkpoint triggered depends on wal size. */ @Test public void testCheckpointStarted_WhenWalHasTooBigSizeWithoutCheckpoint() throws Exception { //given: configured grid with max wal archive size = 1MB, wal segment size = 512KB Ignite ignite = startGrid(dbCfg -> { dbCfg.setMaxWalArchiveSize(1 * 1024 * 1024);// 1 Mbytes }); GridCacheDatabaseSharedManager dbMgr = gridDatabase(ignite); IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(cacheConfiguration()); for (int i = 0; i < 500; i++) cache.put(i, i); //then: checkpoint triggered by size limit of wall without checkpoint GridCacheDatabaseSharedManager.Checkpointer checkpointer = dbMgr.getCheckpointer(); String checkpointReason = U.field((Object)U.field(checkpointer, "curCpProgress"), "reason"); assertEquals("too big size of WAL without checkpoint", checkpointReason); }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); cfg.setConsistentId(gridName); CacheConfiguration<Integer, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfg.setAffinity(new RendezvousAffinityFunction(false, 32)); cfg.setCacheConfiguration(ccfg); DataStorageConfiguration dbCfg = new DataStorageConfiguration(); cfg.setDataStorageConfiguration(dbCfg); dbCfg.setWalSegmentSize(1024 * 1024) .setMaxWalArchiveSize(Long.MAX_VALUE) .setWalSegments(10) .setWalMode(WALMode.LOG_ONLY) .setDefaultDataRegionConfiguration(new DataRegionConfiguration() .setMaxSize(100 * 1024 * 1024) .setPersistenceEnabled(true)); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String name) throws Exception { IgniteConfiguration cfg = super.getConfiguration(name); cfg.setDataStorageConfiguration(new DataStorageConfiguration() .setDefaultDataRegionConfiguration(new DataRegionConfiguration() .setPersistenceEnabled(true) .setMaxSize(200L * 1024 * 1024)) .setWalMode(WALMode.LOG_ONLY) .setWalSegmentSize(512 * 1024) .setWalCompactionEnabled(true) .setMaxWalArchiveSize(2 * 512 * 1024) ); CacheConfiguration ccfg = new CacheConfiguration(); ccfg.setName(DEFAULT_CACHE_NAME); ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); ccfg.setAffinity(new RendezvousAffinityFunction(false, 16)); ccfg.setBackups(0); cfg.setCacheConfiguration(ccfg); cfg.setConsistentId(name); cfg.setIncludeEventTypes(EVT_WAL_SEGMENT_COMPACTED); return cfg; }
.setWriteThrottlingEnabled(in.readBoolean()) .setWalCompactionEnabled(in.readBoolean()) .setMaxWalArchiveSize(in.readLong()) .setSystemRegionInitialSize(in.readLong()) .setSystemRegionMaxSize(in.readLong())
.setWriteThrottlingEnabled(in.readBoolean()) .setWalCompactionEnabled(in.readBoolean()) .setMaxWalArchiveSize(in.readLong()) .setSystemRegionInitialSize(in.readLong()) .setSystemRegionMaxSize(in.readLong())