Search in sources :

Example 1 with GridDhtTxFinishRequest

use of org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishRequest in project ignite by apache.

the class TxPartitionCounterStateAbstractTest method createPrimaryMessagePredicate.

/**
 * @param wrappedPrimSpi Wrapped prim spi.
 * @param futMap Future map.
 * @param nearToLocVerMap Near to local version map.
 * @param cb Callback.
 */
private IgniteBiPredicate<ClusterNode, Message> createPrimaryMessagePredicate(TestRecordingCommunicationSpi wrappedPrimSpi, Map<IgniteUuid, GridCacheVersion> futMap, Map<GridCacheVersion, GridCacheVersion> nearToLocVerMap, TxCallback cb) {
    return (node, msg) -> {
        if (msg instanceof GridDhtTxPrepareRequest) {
            IgniteEx to = IgnitionEx.gridxx(node.id());
            GridDhtTxPrepareRequest req = (GridDhtTxPrepareRequest) msg;
            if (!req.last())
                return false;
            futMap.put(req.futureId(), req.nearXidVersion());
            nearToLocVerMap.put(req.version(), req.nearXidVersion());
            IgniteEx from = fromNode(wrappedPrimSpi);
            IgniteInternalTx primTx = findTx(from, req.nearXidVersion(), true);
            return cb.beforeBackupPrepare(from, to, primTx, createSendFuture(wrappedPrimSpi, msg));
        } else if (msg instanceof GridDhtTxFinishRequest) {
            IgniteEx to = IgnitionEx.gridxx(node.id());
            GridDhtTxFinishRequest req = (GridDhtTxFinishRequest) msg;
            GridCacheVersion nearVer = nearToLocVerMap.get(req.version());
            futMap.put(req.futureId(), nearVer);
            IgniteEx from = fromNode(wrappedPrimSpi);
            IgniteInternalTx primTx = findTx(from, nearVer, true);
            IgniteInternalTx backupTx = findTx(to, nearVer, false);
            return cb.beforeBackupFinish(from, to, primTx, backupTx, nearVer.asIgniteUuid(), createSendFuture(wrappedPrimSpi, msg));
        } else if (msg instanceof GridNearTxPrepareResponse) {
            GridNearTxPrepareResponse resp = (GridNearTxPrepareResponse) msg;
            IgniteEx from = fromNode(wrappedPrimSpi);
            GridCacheVersion ver = futMap.get(resp.futureId());
            IgniteInternalTx primTx = findTx(from, ver, true);
            return cb.afterPrimaryPrepare(from, primTx, ver.asIgniteUuid(), createSendFuture(wrappedPrimSpi, msg));
        } else if (msg instanceof GridNearTxFinishResponse) {
            IgniteEx to = IgnitionEx.gridxx(node.id());
            GridNearTxFinishResponse req = (GridNearTxFinishResponse) msg;
            IgniteEx from = fromNode(wrappedPrimSpi);
            IgniteUuid nearVer = futMap.get(req.futureId()).asIgniteUuid();
            return cb.afterPrimaryFinish(from, nearVer, createSendFuture(wrappedPrimSpi, msg));
        }
        return false;
    };
}
Also used : IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) IgnitionEx(org.apache.ignite.internal.IgnitionEx) TestRecordingCommunicationSpi.spi(org.apache.ignite.internal.TestRecordingCommunicationSpi.spi) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) GridNearTxFinishRequest(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishRequest) Transaction(org.apache.ignite.transactions.Transaction) IgniteEx(org.apache.ignite.internal.IgniteEx) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) GridNearTxPrepareResponse(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareResponse) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) GridDhtTxFinishRequest(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishRequest) CyclicBarrier(java.util.concurrent.CyclicBarrier) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Collection(java.util.Collection) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TransactionConcurrency(org.apache.ignite.transactions.TransactionConcurrency) LOG_ONLY(org.apache.ignite.configuration.WALMode.LOG_ONLY) IgniteWalRebalanceTest(org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteWalRebalanceTest) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) StopNodeFailureHandler(org.apache.ignite.failure.StopNodeFailureHandler) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) PESSIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC) Message(org.apache.ignite.plugin.extensions.communication.Message) Queue(java.util.Queue) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) GridTestUtils.runMultiThreadedAsync(org.apache.ignite.testframework.GridTestUtils.runMultiThreadedAsync) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) IntStream(java.util.stream.IntStream) GridDhtTxPrepareRequest(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareRequest) IgniteBiPredicate(org.apache.ignite.lang.IgniteBiPredicate) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) GridCacheVersion(org.apache.ignite.internal.processors.cache.version.GridCacheVersion) GridCompoundFuture(org.apache.ignite.internal.util.future.GridCompoundFuture) U(org.apache.ignite.internal.util.typedef.internal.U) HashMap(java.util.HashMap) AtomicReference(java.util.concurrent.atomic.AtomicReference) Supplier(java.util.function.Supplier) Collectors.toCollection(java.util.stream.Collectors.toCollection) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) ClusterNode(org.apache.ignite.cluster.ClusterNode) GridDhtTxPrepareResponse(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareResponse) IgniteClosure(org.apache.ignite.lang.IgniteClosure) DAYS(java.util.concurrent.TimeUnit.DAYS) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) GridNearTxPrepareRequest(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareRequest) G(org.apache.ignite.internal.util.typedef.G) F(org.apache.ignite.internal.util.typedef.F) GridNearTxFinishResponse(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishResponse) PartitionUpdateCounter(org.apache.ignite.internal.processors.cache.PartitionUpdateCounter) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) Ignite(org.apache.ignite.Ignite) FULL_SYNC(org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC) T3(org.apache.ignite.internal.util.typedef.T3) TRANSACTIONAL(org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL) T2(org.apache.ignite.internal.util.typedef.T2) GridDhtLocalPartition(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition) GridCacheTxRecoveryRequest(org.apache.ignite.internal.processors.cache.distributed.GridCacheTxRecoveryRequest) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) Collections(java.util.Collections) GridDhtTxFinishResponse(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishResponse) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteUuid(org.apache.ignite.lang.IgniteUuid) GridCacheVersion(org.apache.ignite.internal.processors.cache.version.GridCacheVersion) IgniteUuid(org.apache.ignite.lang.IgniteUuid) IgniteEx(org.apache.ignite.internal.IgniteEx) GridNearTxPrepareResponse(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareResponse) GridDhtTxPrepareRequest(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareRequest) GridDhtTxFinishRequest(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishRequest) GridNearTxFinishResponse(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishResponse)

Example 2 with GridDhtTxFinishRequest

use of org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishRequest in project ignite by apache.

the class GridNearTxFinishFuture method checkBackup.

/**
 */
private void checkBackup() {
    assert !hasFutures() : futures();
    GridDistributedTxMapping mapping = mappings.singleMapping();
    if (mapping != null) {
        UUID nodeId = mapping.primary().id();
        Collection<UUID> backups = tx.transactionNodes().get(nodeId);
        if (!F.isEmpty(backups)) {
            assert backups.size() == 1;
            UUID backupId = F.first(backups);
            ClusterNode backup = cctx.discovery().node(backupId);
            // Nothing to do if backup has left the grid.
            if (backup == null) {
                readyNearMappingFromBackup(mapping);
                ClusterTopologyCheckedException cause = new ClusterTopologyCheckedException("Backup node left grid: " + backupId);
                cause.retryReadyFuture(cctx.nextAffinityReadyFuture(tx.topologyVersion()));
                onDone(new IgniteTxRollbackCheckedException("Failed to commit transaction " + "(backup has left grid): " + tx.xidVersion(), cause));
            } else {
                final CheckBackupMiniFuture mini = new CheckBackupMiniFuture(1, backup, mapping);
                add(mini);
                if (backup.isLocal()) {
                    boolean committed = !cctx.tm().addRolledbackTx(tx);
                    readyNearMappingFromBackup(mapping);
                    if (committed) {
                        try {
                            if (tx.needReturnValue() && tx.implicit()) {
                                GridCacheReturnCompletableWrapper wrapper = cctx.tm().getCommittedTxReturn(tx.xidVersion());
                                assert wrapper != null : tx.xidVersion();
                                GridCacheReturn retVal = wrapper.fut().get();
                                assert retVal != null;
                                tx.implicitSingleResult(retVal);
                            }
                            if (tx.syncMode() == FULL_SYNC) {
                                GridCacheVersion nearXidVer = tx.nearXidVersion();
                                assert nearXidVer != null : tx;
                                IgniteInternalFuture<?> fut = cctx.tm().remoteTxFinishFuture(nearXidVer);
                                fut.listen(new CI1<IgniteInternalFuture<?>>() {

                                    @Override
                                    public void apply(IgniteInternalFuture<?> fut) {
                                        mini.onDone(tx);
                                    }
                                });
                                return;
                            }
                            mini.onDone(tx);
                        } catch (IgniteCheckedException e) {
                            if (msgLog.isDebugEnabled()) {
                                msgLog.debug("Near finish fut, failed to finish [" + "txId=" + tx.nearXidVersion() + ", node=" + backup.id() + ", err=" + e + ']');
                            }
                            mini.onDone(e);
                        }
                    } else {
                        ClusterTopologyCheckedException cause = new ClusterTopologyCheckedException("Primary node left grid: " + nodeId);
                        cause.retryReadyFuture(cctx.nextAffinityReadyFuture(tx.topologyVersion()));
                        mini.onDone(new IgniteTxRollbackCheckedException("Failed to commit transaction " + "(transaction has been rolled back on backup node): " + tx.xidVersion(), cause));
                    }
                } else {
                    GridDhtTxFinishRequest finishReq = checkCommittedRequest(mini.futureId(), false);
                    try {
                        cctx.io().send(backup, finishReq, tx.ioPolicy());
                        if (msgLog.isDebugEnabled()) {
                            msgLog.debug("Near finish fut, sent check committed request [" + "txId=" + tx.nearXidVersion() + ", node=" + backup.id() + ']');
                        }
                    } catch (ClusterTopologyCheckedException ignored) {
                        mini.onNodeLeft(backupId, false);
                    } catch (IgniteCheckedException e) {
                        if (msgLog.isDebugEnabled()) {
                            msgLog.debug("Near finish fut, failed to send check committed request [" + "txId=" + tx.nearXidVersion() + ", node=" + backup.id() + ", err=" + e + ']');
                        }
                        mini.onDone(e);
                    }
                }
            }
        } else
            readyNearMappingFromBackup(mapping);
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridCacheReturn(org.apache.ignite.internal.processors.cache.GridCacheReturn) GridDistributedTxMapping(org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxMapping) GridDhtTxFinishRequest(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishRequest) IgniteTxRollbackCheckedException(org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) GridCacheVersion(org.apache.ignite.internal.processors.cache.version.GridCacheVersion) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) UUID(java.util.UUID) GridCacheReturnCompletableWrapper(org.apache.ignite.internal.processors.cache.GridCacheReturnCompletableWrapper) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)

Example 3 with GridDhtTxFinishRequest

use of org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishRequest in project ignite by apache.

the class GridNearTxFinishFuture method checkCommittedRequest.

/**
 * @param miniId Mini future ID.
 * @param waitRemoteTxs Wait for remote txs.
 * @return Finish request.
 */
private GridDhtTxFinishRequest checkCommittedRequest(int miniId, boolean waitRemoteTxs) {
    GridDhtTxFinishRequest finishReq = new GridDhtTxFinishRequest(cctx.localNodeId(), futureId(), miniId, tx.topologyVersion(), tx.xidVersion(), tx.commitVersion(), tx.threadId(), tx.isolation(), true, false, tx.system(), tx.ioPolicy(), false, tx.syncMode(), null, null, null, null, 0, 0, tx.activeCachesDeploymentEnabled(), !waitRemoteTxs && (tx.needReturnValue() && tx.implicit()), waitRemoteTxs, null, null);
    finishReq.checkCommitted(true);
    return finishReq;
}
Also used : GridDhtTxFinishRequest(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishRequest)

Example 4 with GridDhtTxFinishRequest

use of org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishRequest in project ignite by apache.

the class GridCommandHandlerTest method testKillHangingRemoteTransactions.

/**
 * Simulate uncommitted backup transactions and test rolling back using utility.
 */
@Test
public void testKillHangingRemoteTransactions() throws Exception {
    final int cnt = 3;
    startGridsMultiThreaded(cnt);
    Ignite[] clients = new Ignite[] { startGrid("client1"), startGrid("client2"), startGrid("client3"), startGrid("client4") };
    clients[0].getOrCreateCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME).setBackups(2).setAtomicityMode(TRANSACTIONAL).setWriteSynchronizationMode(FULL_SYNC).setAffinity(new RendezvousAffinityFunction(false, 64)));
    awaitPartitionMapExchange();
    for (Ignite client : clients) {
        assertTrue(client.configuration().isClientMode());
        assertNotNull(client.cache(DEFAULT_CACHE_NAME));
    }
    LongAdder progress = new LongAdder();
    AtomicInteger idx = new AtomicInteger();
    int tc = clients.length;
    CountDownLatch lockLatch = new CountDownLatch(1);
    CountDownLatch commitLatch = new CountDownLatch(1);
    Ignite prim = primaryNode(0L, DEFAULT_CACHE_NAME);
    TestRecordingCommunicationSpi primSpi = TestRecordingCommunicationSpi.spi(prim);
    primSpi.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {

        @Override
        public boolean apply(ClusterNode node, Message message) {
            return message instanceof GridDhtTxFinishRequest;
        }
    });
    Set<IgniteUuid> xidSet = new GridConcurrentHashSet<>();
    IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {

        @Override
        public void run() {
            int id = idx.getAndIncrement();
            Ignite client = clients[id];
            try (Transaction tx = client.transactions().txStart(PESSIMISTIC, READ_COMMITTED, 0, 1)) {
                xidSet.add(tx.xid());
                IgniteCache<Long, Long> cache = client.cache(DEFAULT_CACHE_NAME);
                if (id != 0)
                    U.awaitQuiet(lockLatch);
                cache.invoke(0L, new IncrementClosure(), null);
                if (id == 0) {
                    lockLatch.countDown();
                    U.awaitQuiet(commitLatch);
                    // Wait until candidates will enqueue.
                    doSleep(500);
                }
                tx.commit();
            } catch (Exception e) {
                assertTrue(X.hasCause(e, TransactionTimeoutException.class));
            }
            progress.increment();
        }
    }, tc, "invoke-thread");
    U.awaitQuiet(lockLatch);
    commitLatch.countDown();
    primSpi.waitForBlocked(clients.length);
    // Unblock only finish messages from clients from 2 to 4.
    primSpi.stopBlock(true, blockedMsg -> {
        GridIoMessage iom = blockedMsg.ioMessage();
        Message m = iom.message();
        if (m instanceof GridDhtTxFinishRequest) {
            GridDhtTxFinishRequest r = (GridDhtTxFinishRequest) m;
            return !r.nearNodeId().equals(clients[0].cluster().localNode().id());
        }
        return true;
    });
    // Wait until queue is stable
    for (Ignite ignite : G.allGrids()) {
        if (ignite.configuration().isClientMode())
            continue;
        Collection<IgniteInternalTx> txs = ((IgniteEx) ignite).context().cache().context().tm().activeTransactions();
        waitForCondition(new GridAbsPredicate() {

            @Override
            public boolean apply() {
                for (IgniteInternalTx tx : txs) if (!tx.local()) {
                    IgniteTxEntry entry = tx.writeEntries().iterator().next();
                    GridCacheEntryEx cached = entry.cached();
                    Collection<GridCacheMvccCandidate> candidates = cached.remoteMvccSnapshot();
                    if (candidates.size() != clients.length)
                        return false;
                }
                return true;
            }
        }, 10_000);
    }
    CommandHandler h = new CommandHandler();
    // Check listing.
    validate(h, map -> {
        for (int i = 0; i < cnt; i++) {
            IgniteEx grid = grid(i);
            // Skip primary.
            if (grid.localNode().id().equals(prim.cluster().localNode().id()))
                continue;
            VisorTxTaskResult res = map.get(grid.localNode());
            List<VisorTxInfo> infos = res.getInfos().stream().filter(info -> xidSet.contains(info.getNearXid())).collect(Collectors.toList());
            // Validate queue length on backups.
            assertEquals(clients.length, infos.size());
        }
    }, "--tx");
    // Check kill.
    validate(h, map -> {
    // No-op.
    }, "--tx", "--kill");
    // Wait for all remote txs to finish.
    for (Ignite ignite : G.allGrids()) {
        if (ignite.configuration().isClientMode())
            continue;
        Collection<IgniteInternalTx> txs = ((IgniteEx) ignite).context().cache().context().tm().activeTransactions();
        for (IgniteInternalTx tx : txs) if (!tx.local())
            tx.finishFuture().get();
    }
    // Unblock finish message from client1.
    primSpi.stopBlock(true);
    fut.get();
    Long cur = (Long) clients[0].cache(DEFAULT_CACHE_NAME).get(0L);
    assertEquals(tc - 1, cur.longValue());
    checkUserFutures();
}
Also used : RandomAccessFile(java.io.RandomAccessFile) BlockedWarmUpConfiguration(org.apache.ignite.internal.processors.cache.warmup.BlockedWarmUpConfiguration) Arrays(java.util.Arrays) GridCacheMvccCandidate(org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate) EVT_NODE_LEFT(org.apache.ignite.events.EventType.EVT_NODE_LEFT) UnaryOperator(java.util.function.UnaryOperator) GridConcurrentHashSet(org.apache.ignite.internal.client.util.GridConcurrentHashSet) EntryProcessor(javax.cache.processor.EntryProcessor) BooleanSupplier(java.util.function.BooleanSupplier) GridFunc(org.apache.ignite.internal.util.lang.GridFunc) GridTestUtils.runAsync(org.apache.ignite.testframework.GridTestUtils.runAsync) FileIO(org.apache.ignite.internal.processors.cache.persistence.file.FileIO) REENCRYPTION_RESUME(org.apache.ignite.internal.commandline.encryption.EncryptionSubcommands.REENCRYPTION_RESUME) Matcher(java.util.regex.Matcher) EXIT_CODE_INVALID_ARGUMENTS(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_INVALID_ARGUMENTS) Map(java.util.Map) GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate) Path(java.nio.file.Path) GridDhtTxFinishRequest(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishRequest) VisorTxInfo(org.apache.ignite.internal.visor.tx.VisorTxInfo) IgniteCacheGroupsWithRestartsTest(org.apache.ignite.internal.processors.cache.persistence.db.IgniteCacheGroupsWithRestartsTest) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) INACTIVE(org.apache.ignite.cluster.ClusterState.INACTIVE) GridClientFactory(org.apache.ignite.internal.client.GridClientFactory) CommandHandler(org.apache.ignite.internal.commandline.CommandHandler) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) VisorFindAndDeleteGarbageInPersistenceTaskResult(org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceTaskResult) Set(java.util.Set) ChangeGlobalStateFinishMessage(org.apache.ignite.internal.processors.cluster.ChangeGlobalStateFinishMessage) READ_COMMITTED(org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED) MASTER_KEY_NAME_2(org.apache.ignite.internal.encryption.AbstractEncryptionTest.MASTER_KEY_NAME_2) IgniteCache(org.apache.ignite.IgniteCache) EXIT_CODE_CONNECTION_FAILED(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_CONNECTION_FAILED) Serializable(java.io.Serializable) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) READ_ONLY_SAFE(org.apache.ignite.cache.PartitionLossPolicy.READ_ONLY_SAFE) REENCRYPTION_SUSPEND(org.apache.ignite.internal.commandline.encryption.EncryptionSubcommands.REENCRYPTION_SUSPEND) AbstractSnapshotSelfTest.doSnapshotCancellationTest(org.apache.ignite.internal.processors.cache.persistence.snapshot.AbstractSnapshotSelfTest.doSnapshotCancellationTest) PESSIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC) GridClientImpl(org.apache.ignite.internal.client.impl.GridClientImpl) GridClusterStateProcessor(org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor) Message(org.apache.ignite.plugin.extensions.communication.Message) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) IgniteBiPredicate(org.apache.ignite.lang.IgniteBiPredicate) ClusterState(org.apache.ignite.cluster.ClusterState) U(org.apache.ignite.internal.util.typedef.internal.U) CACHE_GROUP_KEY_IDS(org.apache.ignite.internal.commandline.encryption.EncryptionSubcommands.CACHE_GROUP_KEY_IDS) EntryProcessorException(javax.cache.processor.EntryProcessorException) EXIT_CODE_OK(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_OK) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) REENCRYPTION_RATE(org.apache.ignite.internal.commandline.encryption.EncryptionSubcommands.REENCRYPTION_RATE) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) ClusterNode(org.apache.ignite.cluster.ClusterNode) BlockedWarmUpStrategy(org.apache.ignite.internal.processors.cache.warmup.BlockedWarmUpStrategy) ACTIVE_READ_ONLY(org.apache.ignite.cluster.ClusterState.ACTIVE_READ_ONLY) IgniteInternalTx(org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) REENCRYPTION_STATUS(org.apache.ignite.internal.commandline.encryption.EncryptionSubcommands.REENCRYPTION_STATUS) ACTIVE(org.apache.ignite.cluster.ClusterState.ACTIVE) DEFAULT_TARGET_FOLDER(org.apache.ignite.internal.processors.diagnostic.DiagnosticProcessor.DEFAULT_TARGET_FOLDER) Files(java.nio.file.Files) IOException(java.io.IOException) IgniteSnapshotManager(org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager) VisorTxTaskResult(org.apache.ignite.internal.visor.tx.VisorTxTaskResult) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) Field(java.lang.reflect.Field) BaselineNode(org.apache.ignite.cluster.BaselineNode) File(java.io.File) TRANSACTIONAL(org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL) IgniteTxEntry(org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry) GridNearLockResponse(org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockResponse) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty) AtomicLong(java.util.concurrent.atomic.AtomicLong) TransactionRollbackException(org.apache.ignite.transactions.TransactionRollbackException) TreeMap(java.util.TreeMap) Paths(java.nio.file.Paths) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) IgniteFinishedFutureImpl(org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl) IgniteDataStreamer(org.apache.ignite.IgniteDataStreamer) LongMetric(org.apache.ignite.spi.metric.LongMetric) IgniteUuid(org.apache.ignite.lang.IgniteUuid) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) IgniteAtomicSequence(org.apache.ignite.IgniteAtomicSequence) CheckpointState(org.apache.ignite.internal.processors.cache.persistence.CheckpointState) GridNearTxFinishRequest(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishRequest) SNAPSHOT_METRICS(org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.SNAPSHOT_METRICS) IgniteNodeAttributes(org.apache.ignite.internal.IgniteNodeAttributes) Transaction(org.apache.ignite.transactions.Transaction) CONFIRM_MSG(org.apache.ignite.internal.commandline.CommandHandler.CONFIRM_MSG) GridTestUtils.assertThrows(org.apache.ignite.testframework.GridTestUtils.assertThrows) IgniteEx(org.apache.ignite.internal.IgniteEx) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) MutableEntry(javax.cache.processor.MutableEntry) CHANGE_CACHE_GROUP_KEY(org.apache.ignite.internal.commandline.encryption.EncryptionSubcommands.CHANGE_CACHE_GROUP_KEY) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) X(org.apache.ignite.internal.util.typedef.X) PARTITIONED(org.apache.ignite.cache.CacheMode.PARTITIONED) TestStorageUtils.corruptDataEntry(org.apache.ignite.util.TestStorageUtils.corruptDataEntry) DEACTIVATE(org.apache.ignite.internal.commandline.CommandList.DEACTIVATE) IgniteFuture(org.apache.ignite.lang.IgniteFuture) File.separatorChar(java.io.File.separatorChar) Collection(java.util.Collection) IgniteException(org.apache.ignite.IgniteException) OPTIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC) UUID(java.util.UUID) TransactionProxyImpl(org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl) IGNITE_CLUSTER_NAME(org.apache.ignite.IgniteSystemProperties.IGNITE_CLUSTER_NAME) Collectors(java.util.stream.Collectors) GridIoMessage(org.apache.ignite.internal.managers.communication.GridIoMessage) GRID_NOT_IDLE_MSG(org.apache.ignite.internal.processors.cache.verify.IdleVerifyUtility.GRID_NOT_IDLE_MSG) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) EVT_NODE_FAILED(org.apache.ignite.events.EventType.EVT_NODE_FAILED) CU(org.apache.ignite.internal.util.typedef.internal.CU) Pattern(java.util.regex.Pattern) ShutdownPolicy(org.apache.ignite.ShutdownPolicy) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) ClusterStateTestUtils(org.apache.ignite.internal.processors.cache.ClusterStateTestUtils) NotNull(org.jetbrains.annotations.NotNull) IdleVerifyResultV2(org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2) GridJobExecuteResponse(org.apache.ignite.internal.GridJobExecuteResponse) GridCacheEntryEx(org.apache.ignite.internal.processors.cache.GridCacheEntryEx) IntStream(java.util.stream.IntStream) LongAdder(java.util.concurrent.atomic.LongAdder) GridTestUtils.waitForCondition(org.apache.ignite.testframework.GridTestUtils.waitForCondition) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) IgniteSnapshotManager.resolveSnapshotWorkDirectory(org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.resolveSnapshotWorkDirectory) HashMap(java.util.HashMap) Function(java.util.function.Function) WarmUpTestPluginProvider(org.apache.ignite.internal.processors.cache.warmup.WarmUpTestPluginProvider) ToFileDumpProcessor(org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.dumpprocessors.ToFileDumpProcessor) IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) FileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory) IGNITE_PDS_SKIP_CHECKPOINT_ON_NODE_STOP(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager.IGNITE_PDS_SKIP_CHECKPOINT_ON_NODE_STOP) G(org.apache.ignite.internal.util.typedef.G) F(org.apache.ignite.internal.util.typedef.F) GridNearTxLocal(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal) OpenOption(java.nio.file.OpenOption) AbstractSnapshotSelfTest.snp(org.apache.ignite.internal.processors.cache.persistence.snapshot.AbstractSnapshotSelfTest.snp) FindAndDeleteGarbageArg(org.apache.ignite.internal.commandline.cache.argument.FindAndDeleteGarbageArg) FULL_SYNC(org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC) EXIT_CODE_UNEXPECTED_ERROR(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_UNEXPECTED_ERROR) GridTestUtils.assertContains(org.apache.ignite.testframework.GridTestUtils.assertContains) TimeUnit(java.util.concurrent.TimeUnit) BitSet(java.util.BitSet) Collections(java.util.Collections) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) TransactionTimeoutException(org.apache.ignite.transactions.TransactionTimeoutException) GridIoMessage(org.apache.ignite.internal.managers.communication.GridIoMessage) ChangeGlobalStateFinishMessage(org.apache.ignite.internal.processors.cluster.ChangeGlobalStateFinishMessage) Message(org.apache.ignite.plugin.extensions.communication.Message) GridIoMessage(org.apache.ignite.internal.managers.communication.GridIoMessage) GridDhtTxFinishRequest(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishRequest) CommandHandler(org.apache.ignite.internal.commandline.CommandHandler) GridConcurrentHashSet(org.apache.ignite.internal.client.util.GridConcurrentHashSet) IgniteUuid(org.apache.ignite.lang.IgniteUuid) Ignite(org.apache.ignite.Ignite) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteTxEntry(org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry) GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate) IgniteCache(org.apache.ignite.IgniteCache) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) EntryProcessorException(javax.cache.processor.EntryProcessorException) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) IOException(java.io.IOException) TransactionRollbackException(org.apache.ignite.transactions.TransactionRollbackException) IgniteException(org.apache.ignite.IgniteException) TransactionTimeoutException(org.apache.ignite.transactions.TransactionTimeoutException) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) GridCacheEntryEx(org.apache.ignite.internal.processors.cache.GridCacheEntryEx) LongAdder(java.util.concurrent.atomic.LongAdder) Transaction(org.apache.ignite.transactions.Transaction) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteInternalTx(org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx) TransactionTimeoutException(org.apache.ignite.transactions.TransactionTimeoutException) IgniteEx(org.apache.ignite.internal.IgniteEx) AtomicLong(java.util.concurrent.atomic.AtomicLong) VisorTxInfo(org.apache.ignite.internal.visor.tx.VisorTxInfo) VisorTxTaskResult(org.apache.ignite.internal.visor.tx.VisorTxTaskResult) GridCacheMvccCandidate(org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate) IgniteCacheGroupsWithRestartsTest(org.apache.ignite.internal.processors.cache.persistence.db.IgniteCacheGroupsWithRestartsTest) AbstractSnapshotSelfTest.doSnapshotCancellationTest(org.apache.ignite.internal.processors.cache.persistence.snapshot.AbstractSnapshotSelfTest.doSnapshotCancellationTest) Test(org.junit.Test)

Example 5 with GridDhtTxFinishRequest

use of org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishRequest in project ignite by apache.

the class IgniteTxCachePrimarySyncTest method singleKeyCommitFromPrimary.

/**
 * @param ignite Node executing cache operation.
 * @param ccfg Cache configuration.
 * @param c Cache update closure.
 * @throws Exception If failed.
 */
private void singleKeyCommitFromPrimary(Ignite ignite, final CacheConfiguration<Object, Object> ccfg, IgniteBiInClosure<Integer, IgniteCache<Object, Object>> c) throws Exception {
    TestRecordingCommunicationSpi commSpi0 = (TestRecordingCommunicationSpi) ignite.configuration().getCommunicationSpi();
    IgniteCache<Object, Object> cache = ignite.cache(ccfg.getName());
    final Integer key = primaryKey(cache);
    cache.remove(key);
    waitKeyRemoved(ccfg.getName(), key);
    commSpi0.record(GridDhtTxFinishRequest.class);
    commSpi0.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {

        @Override
        public boolean apply(ClusterNode node, Message msg) {
            return msg instanceof GridDhtTxFinishRequest;
        }
    });
    c.apply(key, cache);
    assertEquals(key, cache.localPeek(key));
    U.sleep(50);
    for (int i = 0; i < SRVS; i++) {
        Ignite node = ignite(i);
        if (node != ignite)
            assertNull(node.cache(DEFAULT_CACHE_NAME).localPeek(key));
    }
    commSpi0.stopBlock(true);
    waitKeyUpdated(ignite, ccfg.getBackups() + 1, ccfg.getName(), key);
    List<Object> msgs = commSpi0.recordedMessages(true);
    assertEquals(ccfg.getBackups(), msgs.size());
    cache.remove(key);
    waitKeyRemoved(ccfg.getName(), key);
    c.apply(key, cache);
    waitKeyUpdated(ignite, ccfg.getBackups() + 1, ccfg.getName(), key);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) Message(org.apache.ignite.plugin.extensions.communication.Message) GridDhtTxFinishRequest(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishRequest) Ignite(org.apache.ignite.Ignite)

Aggregations

GridDhtTxFinishRequest (org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishRequest)7 Ignite (org.apache.ignite.Ignite)5 ClusterNode (org.apache.ignite.cluster.ClusterNode)5 TestRecordingCommunicationSpi (org.apache.ignite.internal.TestRecordingCommunicationSpi)4 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 IgniteEx (org.apache.ignite.internal.IgniteEx)3 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)3 Message (org.apache.ignite.plugin.extensions.communication.Message)3 Collection (java.util.Collection)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 UUID (java.util.UUID)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 GridNearTxFinishRequest (org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishRequest)2 Transaction (org.apache.ignite.transactions.Transaction)2 File (java.io.File)1 File.separatorChar (java.io.File.separatorChar)1