Search in sources :

Example 6 with CheckpointHistory

use of org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointHistory in project ignite by apache.

the class WalRecoveryTxLogicalRecordsTest method reserveWalPointerForIterator.

/**
 * Reserves a WAL pointer for historical iterator.
 *
 * @param cctx Cache shared context.
 * @return WAL pointer.
 */
private WALPointer reserveWalPointerForIterator(GridCacheSharedContext cctx) {
    final CheckpointHistory cpHist = ((GridCacheDatabaseSharedManager) cctx.database()).checkpointHistory();
    WALPointer oldestPtr = cpHist.firstCheckpointPointer();
    AtomicReference<WALPointer> preloading = getFieldValue(cctx.database(), "reservedForPreloading");
    preloading.set(oldestPtr);
    cctx.wal().reserve(oldestPtr);
    return oldestPtr;
}
Also used : GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) CheckpointHistory(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointHistory) WALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer)

Example 7 with CheckpointHistory

use of org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointHistory in project ignite by apache.

the class WalDeletionArchiveAbstractTest method testCorrectDeletedCheckpointHistoryButKeepWalFiles.

/**
 * 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
@WithSystemProperty(key = IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE, value = "2")
public void testCorrectDeletedCheckpointHistoryButKeepWalFiles() throws Exception {
    // given: configured grid with disabled WAL removing.
    Ignite ignite = startGrid(dbCfg -> dbCfg.setMaxWalArchiveSize(DataStorageConfiguration.UNLIMITED_WAL_ARCHIVE));
    GridCacheDatabaseSharedManager dbMgr = gridDatabase(ignite);
    CheckpointHistory hist = dbMgr.checkpointHistory();
    assertNotNull(hist);
    IgniteCache<Integer, Object> 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.
    FileWriteAheadLogManager wal = wal(ignite);
    assertNull(getFieldValueHierarchy(wal, "cleaner"));
    FileDescriptor[] files = wal.walArchiveFiles();
    assertTrue(Stream.of(files).anyMatch(desc -> desc.file().getName().endsWith("0001.wal")));
    assertTrue(hist.checkpoints().size() == 2);
}
Also used : CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) FileWriteAheadLogManager(org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) Arrays(java.util.Arrays) GridTestUtils.waitForCondition(org.apache.ignite.testframework.GridTestUtils.waitForCondition) ClusterState(org.apache.ignite.cluster.ClusterState) U(org.apache.ignite.internal.util.typedef.internal.U) IgniteEx(org.apache.ignite.internal.IgniteEx) IGNITE_CHECKPOINT_TRIGGER_ARCHIVE_SIZE_PERCENTAGE(org.apache.ignite.IgniteSystemProperties.IGNITE_CHECKPOINT_TRIGGER_ARCHIVE_SIZE_PERCENTAGE) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) GridTestUtils.getFieldValueHierarchy(org.apache.ignite.testframework.GridTestUtils.getFieldValueHierarchy) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) Checkpointer(org.apache.ignite.internal.processors.cache.persistence.checkpoint.Checkpointer) WALMode(org.apache.ignite.configuration.WALMode) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) CheckpointHistory(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointHistory) Collection(java.util.Collection) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE(org.apache.ignite.IgniteSystemProperties.IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE) File(java.io.File) IgniteCache(org.apache.ignite.IgniteCache) Consumer(java.util.function.Consumer) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Stream(java.util.stream.Stream) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GB(org.apache.ignite.internal.util.IgniteUtils.GB) MB(org.apache.ignite.internal.util.IgniteUtils.MB) KB(org.apache.ignite.internal.util.IgniteUtils.KB) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) FileDescriptor(org.apache.ignite.internal.processors.cache.persistence.wal.FileDescriptor) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) CheckpointHistory(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointHistory) FileWriteAheadLogManager(org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager) Ignite(org.apache.ignite.Ignite) FileDescriptor(org.apache.ignite.internal.processors.cache.persistence.wal.FileDescriptor) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 8 with CheckpointHistory

use of org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointHistory in project ignite by apache.

the class WalDeletionArchiveAbstractTest method testCorrectDeletedArchivedWalFiles.

/**
 * 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);
    CheckpointHistory hist = dbMgr.checkpointHistory();
    assertNotNull(hist);
    IgniteCache<Integer, Object> cache = ignite.getOrCreateCache(cacheConfiguration());
    // when: put to cache more than 2 MB
    for (int i = 0; i < 500; i++) {
        if (i % 100 == 0)
            forceCheckpoint();
        cache.put(i, i);
    }
    // then: total archive size less than of maxWalArchiveSize(by current logic)
    FileWriteAheadLogManager wal = wal(ignite);
    assertTrue(waitForCondition(() -> wal.lastTruncatedSegment() >= 0, 10_000));
    FileDescriptor[] files = wal.walArchiveFiles();
    long totalSize = wal.totalSize(files);
    assertTrue(files.length >= 1);
    assertTrue(totalSize < maxWalArchiveSize);
    assertFalse(Stream.of(files).anyMatch(desc -> desc.file().getName().endsWith("00001.wal")));
    assertTrue(!hist.checkpoints().isEmpty());
}
Also used : CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) FileWriteAheadLogManager(org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) Arrays(java.util.Arrays) GridTestUtils.waitForCondition(org.apache.ignite.testframework.GridTestUtils.waitForCondition) ClusterState(org.apache.ignite.cluster.ClusterState) U(org.apache.ignite.internal.util.typedef.internal.U) IgniteEx(org.apache.ignite.internal.IgniteEx) IGNITE_CHECKPOINT_TRIGGER_ARCHIVE_SIZE_PERCENTAGE(org.apache.ignite.IgniteSystemProperties.IGNITE_CHECKPOINT_TRIGGER_ARCHIVE_SIZE_PERCENTAGE) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) GridTestUtils.getFieldValueHierarchy(org.apache.ignite.testframework.GridTestUtils.getFieldValueHierarchy) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) Checkpointer(org.apache.ignite.internal.processors.cache.persistence.checkpoint.Checkpointer) WALMode(org.apache.ignite.configuration.WALMode) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) CheckpointHistory(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointHistory) Collection(java.util.Collection) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE(org.apache.ignite.IgniteSystemProperties.IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE) File(java.io.File) IgniteCache(org.apache.ignite.IgniteCache) Consumer(java.util.function.Consumer) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Stream(java.util.stream.Stream) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GB(org.apache.ignite.internal.util.IgniteUtils.GB) MB(org.apache.ignite.internal.util.IgniteUtils.MB) KB(org.apache.ignite.internal.util.IgniteUtils.KB) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) FileDescriptor(org.apache.ignite.internal.processors.cache.persistence.wal.FileDescriptor) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) CheckpointHistory(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointHistory) FileWriteAheadLogManager(org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager) Ignite(org.apache.ignite.Ignite) FileDescriptor(org.apache.ignite.internal.processors.cache.persistence.wal.FileDescriptor) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Aggregations

CheckpointHistory (org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointHistory)8 Test (org.junit.Test)6 Ignite (org.apache.ignite.Ignite)5 IgniteEx (org.apache.ignite.internal.IgniteEx)4 GridCacheDatabaseSharedManager (org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager)4 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)4 File (java.io.File)3 FileWriteAheadLogManager (org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager)3 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)2 Consumer (java.util.function.Consumer)2 Stream (java.util.stream.Stream)2 IgniteCache (org.apache.ignite.IgniteCache)2 IGNITE_CHECKPOINT_TRIGGER_ARCHIVE_SIZE_PERCENTAGE (org.apache.ignite.IgniteSystemProperties.IGNITE_CHECKPOINT_TRIGGER_ARCHIVE_SIZE_PERCENTAGE)2 IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE (org.apache.ignite.IgniteSystemProperties.IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE)2 CacheAtomicityMode (org.apache.ignite.cache.CacheAtomicityMode)2 ClusterState (org.apache.ignite.cluster.ClusterState)2 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)2