Search in sources :

Example 1 with IgniteTxTimeoutCheckedException

use of org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException in project ignite by apache.

the class GridNearOptimisticTxPrepareFuture method onTimeout.

/**
     *
     */
@SuppressWarnings("ForLoopReplaceableByForEach")
private void onTimeout() {
    if (cctx.tm().deadlockDetectionEnabled()) {
        Set<IgniteTxKey> keys = null;
        if (keyLockFut != null)
            keys = new HashSet<>(keyLockFut.lockKeys);
        else {
            synchronized (this) {
                int size = futuresCountNoLock();
                for (int i = 0; i < size; i++) {
                    IgniteInternalFuture<GridNearTxPrepareResponse> fut = future(i);
                    if (isMini(fut) && !fut.isDone()) {
                        MiniFuture miniFut = (MiniFuture) fut;
                        Collection<IgniteTxEntry> entries = miniFut.mapping().entries();
                        keys = U.newHashSet(entries.size());
                        for (IgniteTxEntry entry : entries) keys.add(entry.txKey());
                        break;
                    }
                }
            }
        }
        add(new GridEmbeddedFuture<>(new IgniteBiClosure<TxDeadlock, Exception, GridNearTxPrepareResponse>() {

            @Override
            public GridNearTxPrepareResponse apply(TxDeadlock deadlock, Exception e) {
                if (e != null)
                    U.warn(log, "Failed to detect deadlock.", e);
                else {
                    e = new IgniteTxTimeoutCheckedException("Failed to acquire lock within provided timeout for " + "transaction [timeout=" + tx.timeout() + ", tx=" + tx + ']', deadlock != null ? new TransactionDeadlockException(deadlock.toString(cctx)) : null);
                }
                onDone(null, e);
                return null;
            }
        }, cctx.tm().detectDeadlock(tx, keys)));
    } else {
        ERR_UPD.compareAndSet(this, null, new IgniteTxTimeoutCheckedException("Failed to acquire lock " + "within provided timeout for transaction [timeout=" + tx.timeout() + ", tx=" + tx + ']'));
        onComplete();
    }
}
Also used : IgniteTxEntry(org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry) TransactionDeadlockException(org.apache.ignite.transactions.TransactionDeadlockException) IgniteTxRollbackCheckedException(org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException) ClusterTopologyException(org.apache.ignite.cluster.ClusterTopologyException) IgniteTxTimeoutCheckedException(org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) TransactionDeadlockException(org.apache.ignite.transactions.TransactionDeadlockException) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) GridCacheEntryRemovedException(org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException) TransactionTimeoutException(org.apache.ignite.transactions.TransactionTimeoutException) IgniteBiClosure(org.apache.ignite.lang.IgniteBiClosure) IgniteTxKey(org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey) IgniteTxTimeoutCheckedException(org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException) HashSet(java.util.HashSet) TxDeadlock(org.apache.ignite.internal.processors.cache.transactions.TxDeadlock)

Example 2 with IgniteTxTimeoutCheckedException

use of org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException in project ignite by apache.

the class GridNearOptimisticTxPrepareFuture method prepare0.

/**
     * Initializes future.
     *
     * @param remap Remap flag.
     * @param topLocked {@code True} if thread already acquired lock preventing topology change.
     */
@Override
protected void prepare0(boolean remap, boolean topLocked) {
    try {
        boolean txStateCheck = remap ? tx.state() == PREPARING : tx.state(PREPARING);
        if (!txStateCheck) {
            if (tx.setRollbackOnly()) {
                if (tx.remainingTime() == -1)
                    onError(new IgniteTxTimeoutCheckedException("Transaction timed out and " + "was rolled back: " + this), false);
                else
                    onError(new IgniteCheckedException("Invalid transaction state for prepare " + "[state=" + tx.state() + ", tx=" + this + ']'), false);
            } else
                onError(new IgniteTxRollbackCheckedException("Invalid transaction state for " + "prepare [state=" + tx.state() + ", tx=" + this + ']'), false);
            return;
        }
        IgniteTxEntry singleWrite = tx.singleWrite();
        if (singleWrite != null)
            prepareSingle(singleWrite, topLocked, remap);
        else
            prepare(tx.writeEntries(), topLocked, remap);
        markInitialized();
    } catch (TransactionTimeoutException e) {
        onError(e, false);
    }
}
Also used : IgniteTxEntry(org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) TransactionTimeoutException(org.apache.ignite.transactions.TransactionTimeoutException) IgniteTxTimeoutCheckedException(org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException) IgniteTxRollbackCheckedException(org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException)

Example 3 with IgniteTxTimeoutCheckedException

use of org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException in project ignite by apache.

the class GridNearPessimisticTxPrepareFuture method preparePessimistic.

/**
     *
     */
private void preparePessimistic() {
    Map<UUID, GridDistributedTxMapping> mappings = new HashMap<>();
    AffinityTopologyVersion topVer = tx.topologyVersion();
    GridDhtTxMapping txMapping = new GridDhtTxMapping();
    boolean hasNearCache = false;
    for (IgniteTxEntry txEntry : tx.allEntries()) {
        txEntry.clearEntryReadVersion();
        GridCacheContext cacheCtx = txEntry.context();
        if (cacheCtx.isNear())
            hasNearCache = true;
        List<ClusterNode> nodes;
        if (!cacheCtx.isLocal()) {
            GridDhtPartitionTopology top = cacheCtx.topology();
            nodes = top.nodes(cacheCtx.affinity().partition(txEntry.key()), topVer);
        } else
            nodes = cacheCtx.affinity().nodesByKey(txEntry.key(), topVer);
        assert !nodes.isEmpty();
        ClusterNode primary = nodes.get(0);
        GridDistributedTxMapping nodeMapping = mappings.get(primary.id());
        if (nodeMapping == null)
            mappings.put(primary.id(), nodeMapping = new GridDistributedTxMapping(primary));
        txEntry.nodeId(primary.id());
        nodeMapping.add(txEntry);
        txMapping.addMapping(nodes);
    }
    tx.transactionNodes(txMapping.transactionNodes());
    if (!hasNearCache)
        checkOnePhase(txMapping);
    long timeout = tx.remainingTime();
    if (timeout == -1) {
        onDone(new IgniteTxTimeoutCheckedException("Transaction timed out and was rolled back: " + tx));
        return;
    }
    int miniId = 0;
    Map<UUID, Collection<UUID>> txNodes = txMapping.transactionNodes();
    for (final GridDistributedTxMapping m : mappings.values()) {
        final ClusterNode primary = m.primary();
        if (primary.isLocal()) {
            if (m.hasNearCacheEntries() && m.hasColocatedCacheEntries()) {
                GridNearTxPrepareRequest nearReq = createRequest(txMapping.transactionNodes(), m, timeout, m.nearEntriesReads(), m.nearEntriesWrites());
                prepareLocal(nearReq, m, ++miniId, true);
                GridNearTxPrepareRequest colocatedReq = createRequest(txNodes, m, timeout, m.colocatedEntriesReads(), m.colocatedEntriesWrites());
                prepareLocal(colocatedReq, m, ++miniId, false);
            } else {
                GridNearTxPrepareRequest req = createRequest(txNodes, m, timeout, m.reads(), m.writes());
                prepareLocal(req, m, ++miniId, m.hasNearCacheEntries());
            }
        } else {
            GridNearTxPrepareRequest req = createRequest(txNodes, m, timeout, m.reads(), m.writes());
            final MiniFuture fut = new MiniFuture(m, ++miniId);
            req.miniId(fut.futureId());
            add(fut);
            try {
                cctx.io().send(primary, req, tx.ioPolicy());
                if (msgLog.isDebugEnabled()) {
                    msgLog.debug("Near pessimistic prepare, sent request [txId=" + tx.nearXidVersion() + ", node=" + primary.id() + ']');
                }
            } catch (ClusterTopologyCheckedException e) {
                e.retryReadyFuture(cctx.nextAffinityReadyFuture(topVer));
                fut.onNodeLeft(e);
            } catch (IgniteCheckedException e) {
                if (msgLog.isDebugEnabled()) {
                    msgLog.debug("Near pessimistic prepare, failed send request [txId=" + tx.nearXidVersion() + ", node=" + primary.id() + ", err=" + e + ']');
                }
                fut.onError(e);
                break;
            }
        }
    }
    markInitialized();
}
Also used : IgniteTxEntry(org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry) ClusterNode(org.apache.ignite.cluster.ClusterNode) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) HashMap(java.util.HashMap) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) GridDhtPartitionTopology(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology) GridDistributedTxMapping(org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxMapping) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridDhtTxMapping(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxMapping) Collection(java.util.Collection) IgniteTxTimeoutCheckedException(org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException) UUID(java.util.UUID) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)

Example 4 with IgniteTxTimeoutCheckedException

use of org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException in project ignite by apache.

the class IgniteTxLocalAdapter method userCommit.

/** {@inheritDoc} */
@SuppressWarnings({ "CatchGenericClass" })
@Override
public void userCommit() throws IgniteCheckedException {
    TransactionState state = state();
    if (state != COMMITTING) {
        if (remainingTime() == -1)
            throw new IgniteTxTimeoutCheckedException("Transaction timed out: " + this);
        setRollbackOnly();
        throw new IgniteCheckedException("Invalid transaction state for commit [state=" + state + ", tx=" + this + ']');
    }
    checkValid();
    Collection<IgniteTxEntry> commitEntries = near() ? allEntries() : writeEntries();
    boolean empty = F.isEmpty(commitEntries);
    // locks on backup nodes.
    if (!empty || colocated())
        cctx.tm().addCommittedTx(this);
    if (!empty) {
        batchStoreCommit(writeEntries());
        WALPointer ptr = null;
        cctx.database().checkpointReadLock();
        try {
            cctx.tm().txContext(this);
            AffinityTopologyVersion topVer = topologyVersion();
            /*
                 * Commit to cache. Note that for 'near' transaction we loop through all the entries.
                 */
            for (IgniteTxEntry txEntry : commitEntries) {
                GridCacheContext cacheCtx = txEntry.context();
                GridDrType drType = cacheCtx.isDrEnabled() ? DR_PRIMARY : DR_NONE;
                UUID nodeId = txEntry.nodeId() == null ? this.nodeId : txEntry.nodeId();
                try {
                    while (true) {
                        try {
                            GridCacheEntryEx cached = txEntry.cached();
                            // transaction manager to make sure locks are held.
                            if (!evictNearEntry(txEntry, false)) {
                                if (cacheCtx.isNear() && cacheCtx.dr().receiveEnabled()) {
                                    cached.markObsolete(xidVer);
                                    break;
                                }
                                if (cached.detached())
                                    break;
                                GridCacheEntryEx nearCached = null;
                                boolean metrics = true;
                                if (updateNearCache(cacheCtx, txEntry.key(), topVer))
                                    nearCached = cacheCtx.dht().near().peekEx(txEntry.key());
                                else if (cacheCtx.isNear() && txEntry.locallyMapped())
                                    metrics = false;
                                boolean evt = !isNearLocallyMapped(txEntry, false);
                                if (!F.isEmpty(txEntry.entryProcessors()) || !F.isEmpty(txEntry.filters()))
                                    txEntry.cached().unswap(false);
                                IgniteBiTuple<GridCacheOperation, CacheObject> res = applyTransformClosures(txEntry, true, null);
                                GridCacheVersion dhtVer = null;
                                // backup remote transaction completes.
                                if (cacheCtx.isNear()) {
                                    if (txEntry.op() == CREATE || txEntry.op() == UPDATE || txEntry.op() == DELETE || txEntry.op() == TRANSFORM)
                                        dhtVer = txEntry.dhtVersion();
                                    if ((txEntry.op() == CREATE || txEntry.op() == UPDATE) && txEntry.conflictExpireTime() == CU.EXPIRE_TIME_CALCULATE) {
                                        ExpiryPolicy expiry = cacheCtx.expiryForTxEntry(txEntry);
                                        if (expiry != null) {
                                            txEntry.cached().unswap(false);
                                            Duration duration = cached.hasValue() ? expiry.getExpiryForUpdate() : expiry.getExpiryForCreation();
                                            txEntry.ttl(CU.toTtl(duration));
                                        }
                                    }
                                }
                                GridCacheOperation op = res.get1();
                                CacheObject val = res.get2();
                                // Deal with conflicts.
                                GridCacheVersion explicitVer = txEntry.conflictVersion() != null ? txEntry.conflictVersion() : writeVersion();
                                if ((op == CREATE || op == UPDATE) && txEntry.conflictExpireTime() == CU.EXPIRE_TIME_CALCULATE) {
                                    ExpiryPolicy expiry = cacheCtx.expiryForTxEntry(txEntry);
                                    if (expiry != null) {
                                        Duration duration = cached.hasValue() ? expiry.getExpiryForUpdate() : expiry.getExpiryForCreation();
                                        long ttl = CU.toTtl(duration);
                                        txEntry.ttl(ttl);
                                        if (ttl == CU.TTL_ZERO)
                                            op = DELETE;
                                    }
                                }
                                boolean conflictNeedResolve = cacheCtx.conflictNeedResolve();
                                GridCacheVersionConflictContext<?, ?> conflictCtx = null;
                                if (conflictNeedResolve) {
                                    IgniteBiTuple<GridCacheOperation, GridCacheVersionConflictContext> conflictRes = conflictResolve(op, txEntry, val, explicitVer, cached);
                                    assert conflictRes != null;
                                    conflictCtx = conflictRes.get2();
                                    if (conflictCtx.isUseOld())
                                        op = NOOP;
                                    else if (conflictCtx.isUseNew()) {
                                        txEntry.ttl(conflictCtx.ttl());
                                        txEntry.conflictExpireTime(conflictCtx.expireTime());
                                    } else {
                                        assert conflictCtx.isMerge();
                                        op = conflictRes.get1();
                                        val = txEntry.context().toCacheObject(conflictCtx.mergeValue());
                                        explicitVer = writeVersion();
                                        txEntry.ttl(conflictCtx.ttl());
                                        txEntry.conflictExpireTime(conflictCtx.expireTime());
                                    }
                                } else
                                    // Nullify explicit version so that innerSet/innerRemove will work as usual.
                                    explicitVer = null;
                                if (sndTransformedVals || conflictNeedResolve) {
                                    assert sndTransformedVals && cacheCtx.isReplicated() || conflictNeedResolve;
                                    txEntry.value(val, true, false);
                                    txEntry.op(op);
                                    txEntry.entryProcessors(null);
                                    txEntry.conflictVersion(explicitVer);
                                }
                                if (dhtVer == null)
                                    dhtVer = explicitVer != null ? explicitVer : writeVersion();
                                if (cctx.wal() != null && !writeEntries().isEmpty() && op != NOOP && op != RELOAD && op != READ)
                                    ptr = cctx.wal().log(new DataRecord(new DataEntry(cacheCtx.cacheId(), txEntry.key(), val, op, nearXidVersion(), writeVersion(), 0, txEntry.key().partition(), txEntry.updateCounter())));
                                if (op == CREATE || op == UPDATE) {
                                    GridCacheUpdateTxResult updRes = cached.innerSet(this, eventNodeId(), txEntry.nodeId(), val, false, false, txEntry.ttl(), evt, metrics, txEntry.keepBinary(), txEntry.hasOldValue(), txEntry.oldValue(), topVer, null, cached.detached() ? DR_NONE : drType, txEntry.conflictExpireTime(), cached.isNear() ? null : explicitVer, CU.subjectId(this, cctx), resolveTaskName(), dhtVer, null);
                                    if (updRes.success())
                                        txEntry.updateCounter(updRes.updatePartitionCounter());
                                    if (nearCached != null && updRes.success()) {
                                        nearCached.innerSet(null, eventNodeId(), nodeId, val, false, false, txEntry.ttl(), false, metrics, txEntry.keepBinary(), txEntry.hasOldValue(), txEntry.oldValue(), topVer, CU.empty0(), DR_NONE, txEntry.conflictExpireTime(), null, CU.subjectId(this, cctx), resolveTaskName(), dhtVer, null);
                                    }
                                } else if (op == DELETE) {
                                    GridCacheUpdateTxResult updRes = cached.innerRemove(this, eventNodeId(), txEntry.nodeId(), false, evt, metrics, txEntry.keepBinary(), txEntry.hasOldValue(), txEntry.oldValue(), topVer, null, cached.detached() ? DR_NONE : drType, cached.isNear() ? null : explicitVer, CU.subjectId(this, cctx), resolveTaskName(), dhtVer, null);
                                    if (updRes.success())
                                        txEntry.updateCounter(updRes.updatePartitionCounter());
                                    if (nearCached != null && updRes.success()) {
                                        nearCached.innerRemove(null, eventNodeId(), nodeId, false, false, metrics, txEntry.keepBinary(), txEntry.hasOldValue(), txEntry.oldValue(), topVer, CU.empty0(), DR_NONE, null, CU.subjectId(this, cctx), resolveTaskName(), dhtVer, null);
                                    }
                                } else if (op == RELOAD) {
                                    cached.innerReload();
                                    if (nearCached != null)
                                        nearCached.innerReload();
                                } else if (op == READ) {
                                    ExpiryPolicy expiry = cacheCtx.expiryForTxEntry(txEntry);
                                    if (expiry != null) {
                                        Duration duration = expiry.getExpiryForAccess();
                                        if (duration != null)
                                            cached.updateTtl(null, CU.toTtl(duration));
                                    }
                                    if (log.isDebugEnabled())
                                        log.debug("Ignoring READ entry when committing: " + txEntry);
                                } else {
                                    assert ownsLock(txEntry.cached()) : "Transaction does not own lock for group lock entry during  commit [tx=" + this + ", txEntry=" + txEntry + ']';
                                    if (conflictCtx == null || !conflictCtx.isUseOld()) {
                                        if (txEntry.ttl() != CU.TTL_NOT_CHANGED)
                                            cached.updateTtl(null, txEntry.ttl());
                                    }
                                    if (log.isDebugEnabled())
                                        log.debug("Ignoring NOOP entry when committing: " + txEntry);
                                }
                            }
                            // if an entry is obsolete).
                            if (txEntry.op() != READ)
                                checkCommitLocks(cached);
                            // Break out of while loop.
                            break;
                        }// If entry cached within transaction got removed.
                         catch (GridCacheEntryRemovedException ignored) {
                            if (log.isDebugEnabled())
                                log.debug("Got removed entry during transaction commit (will retry): " + txEntry);
                            txEntry.cached(entryEx(cacheCtx, txEntry.txKey(), topologyVersion()));
                        }
                    }
                } catch (Throwable ex) {
                    // We are about to initiate transaction rollback when tx has started to committing.
                    // Need to remove version from committed list.
                    cctx.tm().removeCommittedTx(this);
                    if (X.hasCause(ex, GridCacheIndexUpdateException.class) && cacheCtx.cache().isMongoDataCache()) {
                        if (log.isDebugEnabled())
                            log.debug("Failed to update mongo document index (transaction entry will " + "be ignored): " + txEntry);
                        // Set operation to NOOP.
                        txEntry.op(NOOP);
                        errorWhenCommitting();
                        throw ex;
                    } else {
                        IgniteCheckedException err = new IgniteTxHeuristicCheckedException("Failed to locally write to cache " + "(all transaction entries will be invalidated, however there was a window when " + "entries for this transaction were visible to others): " + this, ex);
                        U.error(log, "Heuristic transaction failure.", err);
                        COMMIT_ERR_UPD.compareAndSet(this, null, err);
                        state(UNKNOWN);
                        try {
                            // Courtesy to minimize damage.
                            uncommit();
                        } catch (Throwable ex1) {
                            U.error(log, "Failed to uncommit transaction: " + this, ex1);
                            if (ex1 instanceof Error)
                                throw ex1;
                        }
                        if (ex instanceof Error)
                            throw ex;
                        throw err;
                    }
                }
            }
            if (ptr != null)
                cctx.wal().fsync(ptr);
        } catch (StorageException e) {
            throw new IgniteCheckedException("Failed to log transaction record " + "(transaction will be rolled back): " + this, e);
        } finally {
            cctx.database().checkpointReadUnlock();
            cctx.tm().resetContext();
        }
    }
    // Do not unlock transaction entries if one-phase commit.
    if (!onePhaseCommit()) {
        if (DONE_FLAG_UPD.compareAndSet(this, 0, 1)) {
            // Unlock all locks.
            cctx.tm().commitTx(this);
            boolean needsCompletedVersions = needsCompletedVersions();
            assert !needsCompletedVersions || completedBase != null;
            assert !needsCompletedVersions || committedVers != null;
            assert !needsCompletedVersions || rolledbackVers != null;
        }
    }
}
Also used : TransactionState(org.apache.ignite.transactions.TransactionState) IgniteTxHeuristicCheckedException(org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException) DataEntry(org.apache.ignite.internal.pagemem.wal.record.DataEntry) GridCacheVersion(org.apache.ignite.internal.processors.cache.version.GridCacheVersion) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteCacheExpiryPolicy(org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy) ExpiryPolicy(javax.cache.expiry.ExpiryPolicy) GridCacheEntryRemovedException(org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) DataRecord(org.apache.ignite.internal.pagemem.wal.record.DataRecord) UUID(java.util.UUID) WALPointer(org.apache.ignite.internal.pagemem.wal.WALPointer) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) Duration(javax.cache.expiry.Duration) GridCacheVersionConflictContext(org.apache.ignite.internal.processors.cache.version.GridCacheVersionConflictContext) GridCacheEntryEx(org.apache.ignite.internal.processors.cache.GridCacheEntryEx) GridDrType(org.apache.ignite.internal.processors.dr.GridDrType) GridCacheUpdateTxResult(org.apache.ignite.internal.processors.cache.GridCacheUpdateTxResult) IgniteTxTimeoutCheckedException(org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException) GridCacheOperation(org.apache.ignite.internal.processors.cache.GridCacheOperation) StorageException(org.apache.ignite.internal.pagemem.wal.StorageException)

Example 5 with IgniteTxTimeoutCheckedException

use of org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException in project ignite by apache.

the class IgniteTxLocalAdapter method userPrepare.

/**
     * @param entries Entries to lock or {@code null} if use default {@link IgniteInternalTx#optimisticLockEntries()}.
     * @throws IgniteCheckedException If prepare step failed.
     */
@SuppressWarnings({ "CatchGenericClass" })
public void userPrepare(@Nullable Collection<IgniteTxEntry> entries) throws IgniteCheckedException {
    if (state() != PREPARING) {
        if (remainingTime() == -1)
            throw new IgniteTxTimeoutCheckedException("Transaction timed out: " + this);
        TransactionState state = state();
        setRollbackOnly();
        throw new IgniteCheckedException("Invalid transaction state for prepare [state=" + state + ", tx=" + this + ']');
    }
    checkValid();
    try {
        cctx.tm().prepareTx(this, entries);
    } catch (IgniteCheckedException e) {
        throw e;
    } catch (Throwable e) {
        setRollbackOnly();
        if (e instanceof Error)
            throw e;
        throw new IgniteCheckedException("Transaction validation produced a runtime exception: " + this, e);
    }
}
Also used : TransactionState(org.apache.ignite.transactions.TransactionState) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteTxTimeoutCheckedException(org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException)

Aggregations

IgniteCheckedException (org.apache.ignite.IgniteCheckedException)7 IgniteTxTimeoutCheckedException (org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException)7 IgniteTxEntry (org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry)4 IgniteTxRollbackCheckedException (org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException)4 UUID (java.util.UUID)2 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)2 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)2 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)2 GridCacheEntryRemovedException (org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException)2 IgniteTxOptimisticCheckedException (org.apache.ignite.internal.transactions.IgniteTxOptimisticCheckedException)2 TransactionState (org.apache.ignite.transactions.TransactionState)2 TransactionTimeoutException (org.apache.ignite.transactions.TransactionTimeoutException)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Duration (javax.cache.expiry.Duration)1 ExpiryPolicy (javax.cache.expiry.ExpiryPolicy)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 ClusterTopologyException (org.apache.ignite.cluster.ClusterTopologyException)1 StorageException (org.apache.ignite.internal.pagemem.wal.StorageException)1