/** {@inheritDoc} */ @Override public String toString() { return S.toString(SessionData.class, this, "tx", CU.txString(tx != null ? tx.tx : null)); } }
@Override public void run() { // Note: if rollback asynchronously on timeout should not clear thread map // since thread started tx still should be able to see this tx. rollbackNearTxLocalAsync(false, true); U.warn(log, "The transaction was forcibly rolled back because a timeout is reached: " + CU.txString(GridNearTxLocal.this)); } });
/** * @return Rollback exception. */ public final IgniteCheckedException rollbackException() { return new IgniteTxRollbackCheckedException("Failed to finish transaction because it has been rolled back " + "[timeout=" + timeout() + ", tx=" + CU.txString(this) + ']'); }
/** * @return Transaction timeout exception. */ public final IgniteCheckedException timeoutException() { return new IgniteTxTimeoutCheckedException("Failed to acquire lock within provided timeout " + "for transaction [timeout=" + timeout() + ", tx=" + CU.txString(this) + ']'); }
/** * @param log Log. * @param commit Commit. * @param e Exception. */ public void logTxFinishErrorSafe(@Nullable IgniteLogger log, boolean commit, Throwable e) { assert e != null : "Exception is expected"; final String fmt = "Failed completing the transaction: [commit=%s, tx=%s, plc=%s]"; try { // First try printing a full transaction. This is error prone. U.error(log, String.format(fmt, commit, this, cctx.gridConfig().getFailureHandler().getClass().getSimpleName()), e); } catch (Throwable e0) { e.addSuppressed(e0); U.error(log, String.format(fmt, commit, CU.txString(this), cctx.gridConfig().getFailureHandler().getClass().getSimpleName()), e); } }
@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=" + CU.txString(tx) + ']', deadlock != null ? new TransactionDeadlockException(deadlock.toString(cctx)) : null); if (!ERR_UPD.compareAndSet(GridNearOptimisticTxPrepareFuture.this, null, e) && err instanceof IgniteTxTimeoutCheckedException) { err = e; } } onDone(null, e); return null; } }, cctx.tm().detectDeadlock(tx, keys)));
/** * @param nodeId Sender. * @param res Result. */ private boolean onResult0(UUID nodeId, GridNearLockResponse res) { MiniFuture mini = miniFuture(res.miniId()); if (mini != null) { assert mini.node().id().equals(nodeId); mini.onResult(res); return true; } // This warning can be triggered by deadlock detection code which clears pending futures. U.warn(msgLog, "Collocated lock fut, failed to find mini future [txId=" + lockVer + ", tx=" + (inTx() ? CU.txString(tx) : "N/A") + ", node=" + nodeId + ", res=" + res + ", fut=" + this + ']'); return false; }
/** * Rollback transactions blocking partition map exchange. * * @param topVer Initial exchange version. */ public void rollbackOnTopologyChange(AffinityTopologyVersion topVer) { for (IgniteInternalTx tx : activeTransactions()) { if (tx.local() && tx.near() && needWaitTransaction(tx, topVer)) { U.warn(log, "The transaction was forcibly rolled back on partition map exchange because a timeout is " + "reached: [tx=" + CU.txString(tx) + ", topVer=" + topVer + ']'); ((GridNearTxLocal)tx).rollbackNearTxLocalAsync(false, false); } } }
/** {@inheritDoc} */ @Override public final IgniteInternalFuture<T> apply(Boolean locked, @Nullable Exception e) { boolean rollback = true; try { if (e != null) throw new GridClosureException(e); if (!locked) throw new GridClosureException(new IgniteTxTimeoutCheckedException("Failed to acquire lock " + "within provided timeout for transaction [timeout=" + timeout() + ", tx=" + CU.txString(IgniteTxLocalAdapter.this) + ']')); IgniteInternalFuture<T> fut = postLock(); rollback = false; return fut; } catch (IgniteCheckedException ex) { throw new GridClosureException(ex); } finally { if (rollback) setRollbackOnly(); } }
log.error("Failed to cancel lock for the transaction: " + CU.txString(tx), e);
/** * Invalidates transaction. * * @param tx Transaction. * @param status Finalization status. */ private void salvageTx(IgniteInternalTx tx, IgniteInternalTx.FinalizationStatus status) { assert tx != null; TransactionState state = tx.state(); if (state == ACTIVE || state == PREPARING || state == PREPARED || state == MARKED_ROLLBACK) { if (!tx.markFinalizing(status)) { if (log.isInfoEnabled()) log.info("Will not try to commit invalidate transaction (could not mark finalized): " + tx); return; } tx.salvageTx(); if (log.isInfoEnabled()) log.info("Invalidated transaction because originating node left grid: " + CU.txString(tx)); } }
@Override public void apply(IgniteInternalFuture<TxDeadlock> fut) { try { TxDeadlock deadlock = fut.get(); err = new IgniteTxTimeoutCheckedException("Failed to acquire lock within provided " + "timeout for transaction [timeout=" + tx.timeout() + ", tx=" + CU.txString(tx) + ']', deadlock != null ? new TransactionDeadlockException(deadlock.toString(cctx.shared())) : null); } catch (IgniteCheckedException e) { err = e; U.warn(log, "Failed to detect deadlock.", e); } synchronized (LockTimeoutObject.this) { onComplete(false, true); } } });
@Override public void apply(IgniteInternalFuture<TxDeadlock> fut) { try { TxDeadlock deadlock = fut.get(); err = new IgniteTxTimeoutCheckedException("Failed to acquire lock within provided " + "timeout for transaction [timeout=" + tx.timeout() + ", tx=" + CU.txString(tx) + ']', deadlock != null ? new TransactionDeadlockException(deadlock.toString(cctx.shared())) : null); } catch (IgniteCheckedException e) { err = e; U.warn(log, "Failed to detect deadlock.", e); } synchronized (LockTimeoutObject.this) { onComplete(false, true); } } });
/** {@inheritDoc} */ @Override public void apply(IgniteInternalFuture<GridCacheReturn> fut0) { GridDhtTxAbstractEnlistFuture fut = (GridDhtTxAbstractEnlistFuture)fut0; GridCacheContext<?, ?> cctx = fut.cctx; GridDhtTxLocal tx = (GridDhtTxLocal)fut.tx; UUID nearNodeId = fut.nearNodeId; GridNearTxEnlistResponse res = createResponse(fut); try { cctx.io().send(nearNodeId, res, cctx.ioPolicy()); } catch (IgniteCheckedException e) { U.error(fut.log, "Failed to send near enlist response (will rollback transaction) [" + "tx=" + CU.txString(tx) + ", node=" + nearNodeId + ", res=" + res + ']', e); try { tx.rollbackDhtLocalAsync(); } catch (Throwable e1) { e.addSuppressed(e1); } throw new GridClosureException(e); } } }
", holder=" + metaHolder + ", fut=" + fut + ", tx=" + CU.txString(tx) + ']');
/** * Checks transaction expiration. * * @param checkTimeout Whether timeout should be checked. * @throws IgniteCheckedException If transaction check failed. */ protected void checkValid(boolean checkTimeout) throws IgniteCheckedException { if (local() && !dht() && remainingTime() == -1 && checkTimeout) state(MARKED_ROLLBACK, true); if (isRollbackOnly()) { if (remainingTime() == -1) throw new IgniteTxTimeoutCheckedException("Cache transaction timed out: " + CU.txString(this)); TransactionState state = state(); if (state == ROLLING_BACK || state == ROLLED_BACK) throw new IgniteTxRollbackCheckedException("Cache transaction is marked as rollback-only " + "(will be rolled back automatically): " + this); if (state == UNKNOWN) throw new IgniteTxHeuristicCheckedException("Cache transaction is in unknown state " + "(remote transactions will be invalidated): " + this); throw rollbackException(); } }
" transaction: " + CU.txString(tx)));
"for transaction [timeout=" + timeout() + ", tx=" + CU.txString(IgniteTxLocalAdapter.this) + ']', deadlockErr) );
setRollbackOnly(); fut.onError(new IgniteTxRollbackCheckedException("Failed to prepare transaction: " + CU.txString(this), e));