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;
}
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);
}
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());
}
Aggregations