Search in sources :

Example 1 with CheckpointEntry

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

the class GridCacheDatabaseSharedManager method reserveHistoryForExchange.

/**
 * {@inheritDoc}
 */
@Override
public synchronized Map<Integer, Map<Integer, Long>> reserveHistoryForExchange() {
    assert reservedForExchange == null : reservedForExchange;
    Map<Integer, Set<Integer>> /*partId*/
    applicableGroupsAndPartitions = partitionsApplicableForWalRebalance();
    Map<Integer, T2<ReservationReason, Map<Integer, CheckpointEntry>>> /*partId*/
    earliestValidCheckpoints;
    checkpointReadLock();
    WALPointer reservedCheckpointMark;
    try {
        CheckpointHistoryResult checkpointHistoryResult = checkpointHistory().searchAndReserveCheckpoints(applicableGroupsAndPartitions);
        earliestValidCheckpoints = checkpointHistoryResult.earliestValidCheckpoints();
        reservedForExchange = reservedCheckpointMark = checkpointHistoryResult.reservedCheckpointMark();
    } finally {
        checkpointReadUnlock();
    }
    Map<Integer, Map<Integer, Long>> /*updCntr*/
    grpPartsWithCnts = new HashMap<>();
    for (Map.Entry<Integer, T2<ReservationReason, Map<Integer, CheckpointEntry>>> /*partId*/
    e : earliestValidCheckpoints.entrySet()) {
        int grpId = e.getKey();
        if (e.getValue().get2() == null)
            continue;
        for (Map.Entry<Integer, CheckpointEntry> e0 : e.getValue().get2().entrySet()) {
            CheckpointEntry cpEntry = e0.getValue();
            int partId = e0.getKey();
            if (reservedCheckpointMark != null && !cctx.wal().reserved(reservedCheckpointMark)) {
                log.warning("Reservation failed because the segment was released: " + reservedCheckpointMark);
                reservedForExchange = null;
                grpPartsWithCnts.clear();
                return grpPartsWithCnts;
            }
            try {
                Long updCntr = cpEntry.partitionCounter(cctx.wal(), grpId, partId);
                if (updCntr != null)
                    grpPartsWithCnts.computeIfAbsent(grpId, k -> new HashMap<>()).put(partId, updCntr);
            } catch (IgniteCheckedException ex) {
                log.warning("Reservation failed because counters are not available [grpId=" + grpId + ", part=" + partId + ", cp=(" + cpEntry.checkpointId() + ", " + U.format(cpEntry.timestamp()) + ")]", ex);
            }
        }
    }
    if (log.isInfoEnabled() && !F.isEmpty(earliestValidCheckpoints))
        printReservationToLog(earliestValidCheckpoints);
    return grpPartsWithCnts;
}
Also used : CheckpointEntry(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointEntry) Set(java.util.Set) Collectors.toSet(java.util.stream.Collectors.toSet) HashSet(java.util.HashSet) GridConcurrentHashSet(org.apache.ignite.internal.util.GridConcurrentHashSet) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteSystemProperties.getInteger(org.apache.ignite.IgniteSystemProperties.getInteger) CheckpointHistoryResult(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointHistoryResult) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) AtomicLong(java.util.concurrent.atomic.AtomicLong) WALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) T2(org.apache.ignite.internal.util.typedef.T2)

Example 2 with CheckpointEntry

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

the class IgniteWalRecoveryTest method testBinaryRecoverBeforePMEWhenMiddleCheckpoint.

/**
 * Check binary recover completes successfully when node stopped at the middle of checkpoint. Destroy cache_data.bin
 * file for particular cache to emulate missing {@link DynamicCacheDescriptor} file (binary recovery should complete
 * successfully in this case).
 *
 * @throws Exception if failed.
 */
@Test
public void testBinaryRecoverBeforePMEWhenMiddleCheckpoint() throws Exception {
    startGrids(3);
    IgniteEx ig2 = grid(2);
    ig2.cluster().active(true);
    IgniteCache<Object, Object> cache = ig2.cache(CACHE_NAME);
    for (int i = 1; i <= 4_000; i++) cache.put(i, new BigObject(i));
    BigObject objToCheck;
    ig2.getOrCreateCache(CACHE_TO_DESTROY_NAME).put(1, objToCheck = new BigObject(1));
    GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager) ig2.context().cache().context().database();
    IgniteInternalFuture<?> cpFinishFut = dbMgr.forceCheckpoint("force checkpoint").futureFor(FINISHED);
    // Delete checkpoint END file to emulate node stopped at the middle of checkpoint.
    cpFinishFut.listen(new IgniteInClosureX<IgniteInternalFuture>() {

        @Override
        public void applyx(IgniteInternalFuture fut0) throws IgniteCheckedException {
            try {
                CheckpointEntry cpEntry = dbMgr.checkpointHistory().lastCheckpoint();
                String cpEndFileName = CheckpointMarkersStorage.checkpointFileName(cpEntry, CheckpointEntryType.END);
                Files.delete(Paths.get(dbMgr.checkpointDirectory().getAbsolutePath(), cpEndFileName));
                log.info("Checkpoint marker removed [cpEndFileName=" + cpEndFileName + ']');
            } catch (IOException e) {
                throw new IgniteCheckedException(e);
            }
        }
    });
    // Resolve cache directory. Emulating cache destroy in the middle of checkpoint.
    IgniteInternalCache<Object, Object> destoryCache = ig2.cachex(CACHE_TO_DESTROY_NAME);
    FilePageStoreManager pageStoreMgr = (FilePageStoreManager) destoryCache.context().shared().pageStore();
    File destroyCacheWorkDir = pageStoreMgr.cacheWorkDir(destoryCache.configuration());
    // Stop the whole cluster
    stopAllGrids();
    // Delete cache_data.bin file for this cache. Binary recovery should complete successfully after it.
    final File[] files = destroyCacheWorkDir.listFiles(new FilenameFilter() {

        @Override
        public boolean accept(final File dir, final String name) {
            return name.endsWith(CACHE_DATA_FILENAME);
        }
    });
    assertTrue(files.length > 0);
    for (final File file : files) assertTrue("Can't remove " + file.getAbsolutePath(), file.delete());
    startGrids(2);
    // Preprare Ignite instance configuration with additional Discovery checks.
    final String ig2Name = getTestIgniteInstanceName(2);
    final IgniteConfiguration onJoinCfg = optimize(getConfiguration(ig2Name));
    // Check restore beeing called before PME and joining node to cluster.
    ((IgniteDiscoverySpi) onJoinCfg.getDiscoverySpi()).setInternalListener(new DiscoverySpiTestListener() {

        @Override
        public void beforeJoin(ClusterNode locNode, IgniteLogger log) {
            String nodeName = locNode.attribute(ATTR_IGNITE_INSTANCE_NAME);
            GridCacheSharedContext sharedCtx = ((IgniteEx) ignite(getTestIgniteInstanceIndex(nodeName))).context().cache().context();
            if (nodeName.equals(ig2Name)) {
                // Checkpoint history initialized on node start.
                assertFalse(((GridCacheDatabaseSharedManager) sharedCtx.database()).checkpointHistory().checkpoints().isEmpty());
            }
            super.beforeJoin(locNode, log);
        }
    });
    Ignite restoredIg2 = startGrid(ig2Name, onJoinCfg);
    awaitPartitionMapExchange();
    assertEquals(restoredIg2.cache(CACHE_TO_DESTROY_NAME).get(1), objToCheck);
}
Also used : FilePageStoreManager(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) GridCacheSharedContext(org.apache.ignite.internal.processors.cache.GridCacheSharedContext) FilenameFilter(java.io.FilenameFilter) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) DiscoverySpiTestListener(org.apache.ignite.internal.DiscoverySpiTestListener) Ignite(org.apache.ignite.Ignite) CheckpointEntry(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointEntry) ClusterNode(org.apache.ignite.cluster.ClusterNode) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) IOException(java.io.IOException) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteDiscoverySpi(org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi) IgniteLogger(org.apache.ignite.IgniteLogger) File(java.io.File) Test(org.junit.Test) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)

Example 3 with CheckpointEntry

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

the class GridCacheDatabaseSharedManager method reserveHistoryForPreloading.

/**
 * {@inheritDoc}
 */
@Override
public boolean reserveHistoryForPreloading(Map<T2<Integer, Integer>, Long> reservationMap) {
    Map<GroupPartitionId, CheckpointEntry> entries = checkpointHistory().searchCheckpointEntry(reservationMap);
    if (F.isEmpty(entries))
        return false;
    WALPointer oldestWALPointerToReserve = null;
    for (CheckpointEntry cpE : entries.values()) {
        WALPointer ptr = cpE.checkpointMark();
        if (ptr == null)
            return false;
        if (oldestWALPointerToReserve == null || ptr.compareTo(oldestWALPointerToReserve) < 0)
            oldestWALPointerToReserve = ptr;
    }
    if (cctx.wal().reserve(oldestWALPointerToReserve)) {
        reservedForPreloading.set(oldestWALPointerToReserve);
        return true;
    } else
        return false;
}
Also used : CheckpointEntry(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointEntry) WALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer) GroupPartitionId(org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId)

Example 4 with CheckpointEntry

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

the class GridCacheDatabaseSharedManager method printReservationToLog.

/**
 * Prints detail information about caches which were not reserved
 * and reservation depth for the caches which have WAL history enough.
 *
 * @param earliestValidCheckpoints Map contains information about caches' reservation.
 */
private void printReservationToLog(Map<Integer, T2<ReservationReason, Map<Integer, CheckpointEntry>>> earliestValidCheckpoints) {
    try {
        Map<ReservationReason, List<Integer>> notReservedCachesToPrint = new HashMap<>();
        Map<ReservationReason, List<T2<Integer, CheckpointEntry>>> reservedCachesToPrint = new HashMap<>();
        for (Map.Entry<Integer, T2<ReservationReason, Map<Integer, CheckpointEntry>>> entry : earliestValidCheckpoints.entrySet()) {
            if (entry.getValue().get2() == null) {
                notReservedCachesToPrint.computeIfAbsent(entry.getValue().get1(), reason -> new ArrayList<>()).add(entry.getKey());
            } else {
                reservedCachesToPrint.computeIfAbsent(entry.getValue().get1(), reason -> new ArrayList<>()).add(new T2(entry.getKey(), entry.getValue().get2().values().stream().min(Comparator.comparingLong(CheckpointEntry::timestamp)).get()));
            }
        }
        if (!F.isEmpty(notReservedCachesToPrint)) {
            log.info("Cache groups were not reserved [" + notReservedCachesToPrint.entrySet().stream().map(entry -> '[' + entry.getValue().stream().map(grpId -> "[grpId=" + grpId + ", grpName=" + cctx.cache().cacheGroup(grpId).cacheOrGroupName() + ']').collect(Collectors.joining(", ")) + ", reason=" + entry.getKey() + ']').collect(Collectors.joining(", ")) + ']');
        }
        if (!F.isEmpty(reservedCachesToPrint)) {
            log.info("Cache groups with earliest reserved checkpoint and a reason why a previous checkpoint was inapplicable: [" + reservedCachesToPrint.entrySet().stream().map(entry -> '[' + entry.getValue().stream().map(grpCp -> "[grpId=" + grpCp.get1() + ", grpName=" + cctx.cache().cacheGroup(grpCp.get1()).cacheOrGroupName() + ", cp=(" + grpCp.get2().checkpointId() + ", " + U.format(grpCp.get2().timestamp()) + ")]").collect(Collectors.joining(", ")) + ", reason=" + entry.getKey() + ']').collect(Collectors.joining(", ")) + ']');
        }
    } catch (Exception e) {
        log.error("An error happened during printing partitions that were reserved for potential historical rebalance.", e);
    }
}
Also used : CheckpointEntry(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointEntry) Arrays(java.util.Arrays) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) TxLog(org.apache.ignite.internal.processors.cache.mvcc.txlog.TxLog) PartitionClearingStartRecord(org.apache.ignite.internal.pagemem.wal.record.PartitionClearingStartRecord) DistributedConfigurationLifecycleListener(org.apache.ignite.internal.processors.configuration.distributed.DistributedConfigurationLifecycleListener) MetastorageLifecycleListener(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetastorageLifecycleListener) CheckpointStatus(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointStatus) MASTER_KEY_CHANGE_RECORD(org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordType.MASTER_KEY_CHANGE_RECORD) METASTORE_DATA_RECORD(org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordType.METASTORE_DATA_RECORD) FileIO(org.apache.ignite.internal.processors.cache.persistence.file.FileIO) GridPortRecord(org.apache.ignite.internal.processors.port.GridPortRecord) LightweightCheckpointManager(org.apache.ignite.internal.processors.cache.persistence.checkpoint.LightweightCheckpointManager) PagePartitionMetaIO(org.apache.ignite.internal.processors.cache.persistence.tree.io.PagePartitionMetaIO) GridDhtPartitionState.fromOrdinal(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.fromOrdinal) MaintenanceRegistry(org.apache.ignite.maintenance.MaintenanceRegistry) Map(java.util.Map) PageUtils(org.apache.ignite.internal.pagemem.PageUtils) IGNITE_PREFER_WAL_REBALANCE(org.apache.ignite.IgniteSystemProperties.IGNITE_PREFER_WAL_REBALANCE) Path(java.nio.file.Path) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) PageIdAllocator(org.apache.ignite.internal.pagemem.PageIdAllocator) IgniteDataIntegrityViolationException(org.apache.ignite.internal.processors.cache.persistence.wal.crc.IgniteDataIntegrityViolationException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor) Set(java.util.Set) DataEntry(org.apache.ignite.internal.pagemem.wal.record.DataEntry) Serializable(java.io.Serializable) ByteOrder(java.nio.ByteOrder) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgnitePageStoreManager(org.apache.ignite.internal.pagemem.store.IgnitePageStoreManager) CheckpointHistoryResult(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointHistoryResult) GB(org.apache.ignite.internal.util.IgniteUtils.GB) GridCountDownCallback(org.apache.ignite.internal.util.GridCountDownCallback) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) PageSnapshot(org.apache.ignite.internal.pagemem.wal.record.PageSnapshot) WALIterator(org.apache.ignite.internal.pagemem.wal.WALIterator) IgniteBiPredicate(org.apache.ignite.lang.IgniteBiPredicate) FullPageId(org.apache.ignite.internal.pagemem.FullPageId) U(org.apache.ignite.internal.util.typedef.internal.U) IgniteLogger(org.apache.ignite.IgniteLogger) PageMemory(org.apache.ignite.internal.pagemem.PageMemory) IGNITE_RECOVERY_SEMAPHORE_PERMITS(org.apache.ignite.IgniteSystemProperties.IGNITE_RECOVERY_SEMAPHORE_PERMITS) ArrayList(java.util.ArrayList) GridKernalContext(org.apache.ignite.internal.GridKernalContext) CheckpointManager(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointManager) ClusterNode(org.apache.ignite.cluster.ClusterNode) GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture) IgniteInterruptedException(org.apache.ignite.IgniteInterruptedException) PageReadWriteManager(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageReadWriteManager) MvccDataEntry(org.apache.ignite.internal.pagemem.wal.record.MvccDataEntry) CheckpointListener(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointListener) FINISHED(org.apache.ignite.internal.processors.cache.persistence.CheckpointState.FINISHED) IgniteTxManager(org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager) CachePartitionDefragmentationManager(org.apache.ignite.internal.processors.cache.persistence.defragmentation.CachePartitionDefragmentationManager) PageIdUtils.partId(org.apache.ignite.internal.pagemem.PageIdUtils.partId) DataStorageMetrics(org.apache.ignite.DataStorageMetrics) IoStatisticsHolderNoOp(org.apache.ignite.internal.metric.IoStatisticsHolderNoOp) TX_RECORD(org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordType.TX_RECORD) SystemProperty(org.apache.ignite.SystemProperty) A(org.apache.ignite.internal.util.typedef.internal.A) IOException(java.io.IOException) MaintenanceTask(org.apache.ignite.maintenance.MaintenanceTask) IGNITE_PDS_WAL_REBALANCE_THRESHOLD(org.apache.ignite.IgniteSystemProperties.IGNITE_PDS_WAL_REBALANCE_THRESHOLD) File(java.io.File) T2(org.apache.ignite.internal.util.typedef.T2) PageMemoryImpl(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryImpl) SimpleDistributedProperty(org.apache.ignite.internal.processors.configuration.distributed.SimpleDistributedProperty) AtomicLong(java.util.concurrent.atomic.AtomicLong) GridDhtLocalPartition(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition) GridCacheSharedContext(org.apache.ignite.internal.processors.cache.GridCacheSharedContext) DefragmentationPageReadWriteManager(org.apache.ignite.internal.processors.cache.persistence.defragmentation.DefragmentationPageReadWriteManager) IgniteCacheSnapshotManager(org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteCacheSnapshotManager) GridInClosure3X(org.apache.ignite.internal.util.lang.GridInClosure3X) WalRecordCacheGroupAware(org.apache.ignite.internal.pagemem.wal.record.WalRecordCacheGroupAware) CompressionProcessor(org.apache.ignite.internal.processors.compress.CompressionProcessor) DefragmentationParameters.fromStore(org.apache.ignite.internal.processors.cache.persistence.defragmentation.maintenance.DefragmentationParameters.fromStore) PartitionDestroyRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PartitionDestroyRecord) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) PageStore(org.apache.ignite.internal.pagemem.store.PageStore) StripedExecutor(org.apache.ignite.internal.util.StripedExecutor) IgniteSystemProperties.getBoolean(org.apache.ignite.IgniteSystemProperties.getBoolean) TimeBag(org.apache.ignite.internal.util.TimeBag) TRANSACTIONAL_SNAPSHOT(org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT) WALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer) ByteBuffer(java.nio.ByteBuffer) IgniteSystemProperties(org.apache.ignite.IgniteSystemProperties) RollbackRecord(org.apache.ignite.internal.pagemem.wal.record.RollbackRecord) IgniteUtils.checkpointBufferSize(org.apache.ignite.internal.util.IgniteUtils.checkpointBufferSize) SB(org.apache.ignite.internal.util.typedef.internal.SB) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DataRegionMetricsProvider(org.apache.ignite.DataRegionMetricsProvider) TxRecord(org.apache.ignite.internal.pagemem.wal.record.TxRecord) X(org.apache.ignite.internal.util.typedef.X) DataStorageMetricsMXBean(org.apache.ignite.mxbean.DataStorageMetricsMXBean) Checkpointer(org.apache.ignite.internal.processors.cache.persistence.checkpoint.Checkpointer) DefragmentationWorkflowCallback(org.apache.ignite.internal.processors.cache.persistence.defragmentation.maintenance.DefragmentationWorkflowCallback) IGNITE_DEFRAGMENTATION_REGION_SIZE_PERCENTAGE(org.apache.ignite.IgniteSystemProperties.IGNITE_DEFRAGMENTATION_REGION_SIZE_PERCENTAGE) ToLongFunction(java.util.function.ToLongFunction) GridDhtPartitionState(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState) MetastorageViewWalker(org.apache.ignite.internal.managers.systemview.walker.MetastorageViewWalker) FilePageStore(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStore) Collectors.toSet(java.util.stream.Collectors.toSet) DEFRAGMENTATION_MNTC_TASK_NAME(org.apache.ignite.internal.processors.cache.persistence.defragmentation.CachePartitionDefragmentationManager.DEFRAGMENTATION_MNTC_TASK_NAME) FailureType(org.apache.ignite.failure.FailureType) CacheState(org.apache.ignite.internal.pagemem.wal.record.CacheState) IgniteOutClosure(org.apache.ignite.lang.IgniteOutClosure) Predicate(java.util.function.Predicate) Collections.emptyList(java.util.Collections.emptyList) Collection(java.util.Collection) IgniteException(org.apache.ignite.IgniteException) WALRecord(org.apache.ignite.internal.pagemem.wal.record.WALRecord) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) FilePageStoreManager(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager) MetaStorage(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage) OWNING(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.OWNING) UUID(java.util.UUID) DirectMemoryProvider(org.apache.ignite.internal.mem.DirectMemoryProvider) DataRecord(org.apache.ignite.internal.pagemem.wal.record.DataRecord) Collectors(java.util.stream.Collectors) IgniteCacheOffheapManager(org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager) IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) PageDeltaRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PageDeltaRecord) DataRegionMetrics(org.apache.ignite.DataRegionMetrics) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) DistributedPropertyDispatcher(org.apache.ignite.internal.processors.configuration.distributed.DistributedPropertyDispatcher) CU(org.apache.ignite.internal.util.typedef.internal.CU) Function.identity(java.util.function.Function.identity) CheckpointEntry(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointEntry) Pattern(java.util.regex.Pattern) NotNull(org.jetbrains.annotations.NotNull) Objects.nonNull(java.util.Objects.nonNull) IgniteSystemProperties.getInteger(org.apache.ignite.IgniteSystemProperties.getInteger) CHECKPOINT_LOCK_HOLD_COUNT(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointReadWriteLock.CHECKPOINT_LOCK_HOLD_COUNT) CheckpointProgress(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointProgress) HashMap(java.util.HashMap) MvccTxRecord(org.apache.ignite.internal.pagemem.wal.record.MvccTxRecord) AtomicReference(java.util.concurrent.atomic.AtomicReference) DirectMemoryRegion(org.apache.ignite.internal.mem.DirectMemoryRegion) CacheGroupContext(org.apache.ignite.internal.processors.cache.CacheGroupContext) HashSet(java.util.HashSet) IndexRenameRootPageRecord(org.apache.ignite.internal.pagemem.wal.record.IndexRenameRootPageRecord) FailureContext(org.apache.ignite.failure.FailureContext) IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) MasterKeyChangeRecordV2(org.apache.ignite.internal.pagemem.wal.record.MasterKeyChangeRecordV2) IgniteUtils(org.apache.ignite.internal.util.IgniteUtils) FileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) PageIO(org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO) NoSuchElementException(java.util.NoSuchElementException) MemoryRecoveryRecord(org.apache.ignite.internal.pagemem.wal.record.MemoryRecoveryRecord) MetastorageView(org.apache.ignite.spi.systemview.view.MetastorageView) GridDiscoveryManager(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager) F(org.apache.ignite.internal.util.typedef.F) MetastoreDataRecord(org.apache.ignite.internal.pagemem.wal.record.MetastoreDataRecord) ReencryptionStartRecord(org.apache.ignite.internal.pagemem.wal.record.ReencryptionStartRecord) GroupPartitionId(org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId) Iterator(java.util.Iterator) Semaphore(java.util.concurrent.Semaphore) CheckpointHistory(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointHistory) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) DynamicCacheDescriptor(org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor) DataPageEvictionMode(org.apache.ignite.configuration.DataPageEvictionMode) GridConcurrentHashSet(org.apache.ignite.internal.util.GridConcurrentHashSet) CHECKPOINT_RECORD(org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordType.CHECKPOINT_RECORD) CheckpointRecord(org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord) Consumer(java.util.function.Consumer) DistributedConfigurationUtils.makeUpdateListener(org.apache.ignite.internal.cluster.DistributedConfigurationUtils.makeUpdateListener) PartitionMetaStateRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PartitionMetaStateRecord) DistributedConfigurationUtils.setDefaultValue(org.apache.ignite.internal.cluster.DistributedConfigurationUtils.setDefaultValue) Collectors.toList(java.util.stream.Collectors.toList) TransactionState(org.apache.ignite.transactions.TransactionState) LOCK_RELEASED(org.apache.ignite.internal.processors.cache.persistence.CheckpointState.LOCK_RELEASED) PageMemoryEx(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryEx) MASTER_KEY_CHANGE_RECORD_V2(org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordType.MASTER_KEY_CHANGE_RECORD_V2) Comparator(java.util.Comparator) Collections(java.util.Collections) TxState(org.apache.ignite.internal.processors.cache.mvcc.txlog.TxState) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) ReservationReason(org.apache.ignite.internal.processors.cache.persistence.checkpoint.ReservationReason) GridQueryProcessor(org.apache.ignite.internal.processors.query.GridQueryProcessor) CORRUPTED_DATA_FILES_MNTC_TASK_NAME(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CORRUPTED_DATA_FILES_MNTC_TASK_NAME) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ReservationReason(org.apache.ignite.internal.processors.cache.persistence.checkpoint.ReservationReason) IgniteDataIntegrityViolationException(org.apache.ignite.internal.processors.cache.persistence.wal.crc.IgniteDataIntegrityViolationException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteInterruptedException(org.apache.ignite.IgniteInterruptedException) IOException(java.io.IOException) IgniteException(org.apache.ignite.IgniteException) NoSuchElementException(java.util.NoSuchElementException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteSystemProperties.getInteger(org.apache.ignite.IgniteSystemProperties.getInteger) ArrayList(java.util.ArrayList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) T2(org.apache.ignite.internal.util.typedef.T2)

Example 5 with CheckpointEntry

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

the class GridCacheDatabaseSharedManager method lastCheckpointInapplicableForWalRebalance.

/**
 * Set last checkpoint as inapplicable for WAL rebalance for given group {@code grpId}.
 *
 * @param grpId Group ID.
 */
@Override
public void lastCheckpointInapplicableForWalRebalance(int grpId) {
    checkpointReadLock();
    try {
        CheckpointEntry lastCp = checkpointManager.checkpointMarkerStorage().removeFromEarliestCheckpoints(grpId);
        long lastCpTs = lastCp != null ? lastCp.timestamp() : 0;
        if (lastCpTs != 0)
            metaStorage.write(checkpointInapplicableCpAndGroupIdToKey(lastCpTs, grpId), true);
    } catch (IgniteCheckedException e) {
        log.error("Failed to mark last checkpoint as inapplicable for WAL rebalance for group: " + grpId, e);
    } finally {
        checkpointReadUnlock();
    }
}
Also used : CheckpointEntry(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointEntry) IgniteCheckedException(org.apache.ignite.IgniteCheckedException)

Aggregations

CheckpointEntry (org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointEntry)5 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 WALPointer (org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer)3 File (java.io.File)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Set (java.util.Set)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 Collectors.toSet (java.util.stream.Collectors.toSet)2 GroupPartitionId (org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId)2 FilenameFilter (java.io.FilenameFilter)1 Serializable (java.io.Serializable)1 ByteBuffer (java.nio.ByteBuffer)1 ByteOrder (java.nio.ByteOrder)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1