MvccUtils.requestSnapshot(cacheCtx, this); beforePut(cacheCtx, retval, true); if (implicit()) try { commit(); if (isRollbackOnly()) return new GridFinishedFuture<>(timedOut() ? timeoutException() : rollbackException()); rollback(); setRollbackOnly(); return updateAsync(cacheCtx, new UpdateSourceIterator<IgniteBiTuple<KeyCacheObject, Object>>() { }, retval, filter, remainingTime(), true); onException();
/** * @param e Error. */ void onNodeLeft(ClusterTopologyCheckedException e) { if (msgLog.isDebugEnabled()) { msgLog.debug("Near pessimistic prepare, mini future node left [txId=" + tx.nearXidVersion() + ", nodeId=" + m.primary().id() + ']'); } if (tx.onePhaseCommit()) { tx.markForBackupCheck(); // Do not fail future for one-phase transaction right away. onDone((GridNearTxPrepareResponse)null); } onError(e); }
/** {@inheritDoc} */ @Override public void beforeCompletion() { if (log.isDebugEnabled()) log.debug("Synchronization.beforeCompletion() [xid=" + cacheTx.xid() + "]"); if (cacheTx.state() != ACTIVE) throw new CacheException("Cache transaction is not in active state."); try { cacheTx.prepare(true); } catch (IgniteCheckedException e) { throw new CacheException("Failed to prepare cache transaction.", e); } }
/** * Commits active transaction if exists. * * @throws IgniteCheckedException If failed. */ private void finishActiveTxIfNecessary() throws IgniteCheckedException { try (GridNearTxLocal tx = MvccUtils.tx(ctx)) { if (tx == null) return; if (!tx.isRollbackOnly()) tx.commit(); else tx.rollback(); } }
/** * @param tx Transaction to close. * @throws IgniteCheckedException If failed. */ public void endTx(GridNearTxLocal tx) throws IgniteCheckedException { boolean clearThreadMap = txMgr.threadLocalTx(null) == tx; if (clearThreadMap) tx.txState().awaitLastFuture(this); else tx.state(MARKED_ROLLBACK); tx.close(clearThreadMap); }
/** * @param tx Transaction to rollback. * @throws IgniteCheckedException If failed. * @return Rollback future. */ public IgniteInternalFuture rollbackTxAsync(GridNearTxLocal tx) throws IgniteCheckedException { boolean clearThreadMap = txMgr.threadLocalTx(null) == tx; if (clearThreadMap) tx.txState().awaitLastFuture(this); else tx.state(MARKED_ROLLBACK); return tx.rollbackNearTxLocalAsync(clearThreadMap, false); }
boolean singleRmv) { if(cacheCtx.mvccEnabled()) return mvccRemoveAllAsync0(cacheCtx, keys, retval, filter); checkUpdatesAllowed(cacheCtx); needReturnValue(true); checkValid(); final GridCacheReturn ret = new GridCacheReturn(localResult(), false); if (implicit()) { try { commit(); init(); final IgniteInternalFuture<Void> loadFut = enlistWrite( cacheCtx, entryTopVer, long timeout = remainingTime(); return new GridFinishedFuture<>(timeoutException()); if (isRollbackOnly()) return new GridFinishedFuture<>(rollbackException());
return mvccPutAllAsync0(cacheCtx, Collections.singletonMap(key, val), entryProcessor == null ? null : Collections.singletonMap(key, entryProcessor), invokeArgs, retval, filter); beforePut(cacheCtx, retval, false); final GridCacheReturn ret = new GridCacheReturn(localResult(), false); final IgniteInternalFuture<Void> loadFut = enlistWrite( cacheCtx, entryTopVer, long timeout = remainingTime(); return new GridFinishedFuture<>(timeoutException()); if (isRollbackOnly()) return new GridFinishedFuture<>(rollbackException()); if (pessimistic()) { final Collection<KeyCacheObject> enlisted = Collections.singleton(cacheKey); retval, isolation, isInvalidate(), -1L, -1L); return nonInterruptable(plc1.apply(fut.get(), null));
assert !m.empty() || m.queryUpdate() : m + " " + tx.state(); CacheWriteSynchronizationMode syncMode = tx.syncMode(); tx.xidVersion(), tx.threadId(), commit, tx.isInvalidate(), tx.system(), tx.ioPolicy(), syncMode, m.explicitLock(), tx.storeEnabled(), tx.topologyVersion(), null, null, null, tx.size(), tx.subjectId(), tx.taskNameHash(), tx.mvccSnapshot(), tx.activeCachesDeploymentEnabled() ); if (tx.pessimistic() && !useCompletedVer) cctx.tm().beforeFinishRemote(n.id(), tx.threadId()); cctx.io().send(n, req, tx.ioPolicy());
MvccUtils.requestSnapshot(cacheCtx, this); beforeRemove(cacheCtx, retval, true); if (implicit()) { try { commit(); return new GridFinishedFuture<>(new GridCacheReturn(localResult(), true)); init(); if (isRollbackOnly()) return new GridFinishedFuture<>(timedOut() ? timeoutException() : rollbackException()); rollback(); return updateAsync(cacheCtx, new UpdateSourceIterator<KeyCacheObject>() { return it.next(); }, retval, filter, remainingTime(), true);
/** * Initializes future. * * @param remap Remap flag. */ @Override protected void prepare0(boolean remap, boolean topLocked) { boolean txStateCheck = remap ? tx.state() == PREPARING : tx.state(PREPARING); if (!txStateCheck) { if (tx.isRollbackOnly() || tx.setRollbackOnly()) { if (tx.timedOut()) onDone(null, tx.timeoutException()); else onDone(null, tx.rollbackException()); } else onDone(null, new IgniteCheckedException("Invalid transaction state for " + "prepare [state=" + tx.state() + ", tx=" + this + ']')); return; } boolean set = cctx.tm().setTxTopologyHint(tx.topologyVersionSnapshot()); try { prepare(tx.readEntries(), tx.writeEntries(), remap, topLocked); markInitialized(); } finally { if (set) cctx.tm().setTxTopologyHint(null); } }
boolean txStateCheck = remap ? tx.state() == PREPARING : tx.state(PREPARING); if (tx.isRollbackOnly() || tx.setRollbackOnly()) { if (tx.remainingTime() == -1) onDone(tx.timeoutException()); else onDone(tx.rollbackException()); "prepare [state=" + tx.state() + ", tx=" + this + ']')); IgniteTxEntry singleWrite = tx.singleWrite(); prepare(tx.writeEntries(), topLocked, remap);
/** {@inheritDoc} */ @Override public void prepare() { if (!tx.state(PREPARING)) { if (tx.isRollbackOnly() || tx.setRollbackOnly()) { if (tx.remainingTime() == -1) onDone(tx.timeoutException()); else onDone(tx.rollbackException()); } else onDone(new IgniteCheckedException("Invalid transaction state for prepare " + "[state=" + tx.state() + ", tx=" + this + ']')); return; } try { tx.userPrepare(Collections.<IgniteTxEntry>emptyList()); cctx.mvcc().addFuture(this); preparePessimistic(); } catch (IgniteCheckedException e) { onDone(e); } }
/** {@inheritDoc} */ @Override public boolean onDone(@Nullable IgniteInternalTx res, @Nullable Throwable err) { if (err != null) ERR_UPD.compareAndSet(GridNearPessimisticTxPrepareFuture.this, null, err); err = this.err; if ((!tx.onePhaseCommit() || tx.mappings().get(cctx.localNodeId()) == null) && (err == null || tx.needCheckBackup())) tx.state(PREPARED); if (super.onDone(tx, err)) { cctx.mvcc().removeVersionedFuture(this); return true; } return false; }
if (!state(COMMITTING)) { TransactionState state = state(); throw isRollbackOnly() ? timedOut() ? timeoutException() : rollbackException() : new IgniteCheckedException("Invalid transaction state for commit [state=" + state() + ", tx=" + this + ']'); else { if (!state(ROLLING_BACK)) { if (log.isDebugEnabled()) log.debug("Invalid transaction state for rollback [state=" + state() + ", tx=" + this + ']'); if (commit && !isRollbackOnly()) userCommit(); else userRollback(clearThreadMap); if (!isRollbackOnly()) { invalidate = true; systemInvalidate(true); state(UNKNOWN); if (!onePhaseCommit()) { if (!state(COMMITTED)) { state(UNKNOWN); if (!state(ROLLED_BACK)) {
Collection<UUID> backups = tx.transactionNodes().get(nodeId); cause.retryReadyFuture(cctx.nextAffinityReadyFuture(tx.topologyVersion())); "(backup has left grid): " + tx.xidVersion(), cause)); if (tx.needReturnValue() && tx.implicit()) { GridCacheReturnCompletableWrapper wrapper = cctx.tm().getCommittedTxReturn(tx.xidVersion()); assert wrapper != null : tx.xidVersion(); tx.implicitSingleResult(retVal); if (tx.syncMode() == FULL_SYNC) { GridCacheVersion nearXidVer = tx.nearXidVersion(); if (msgLog.isDebugEnabled()) { msgLog.debug("Near finish fut, failed to finish [" + "txId=" + tx.nearXidVersion() + ", node=" + backup.id() + ", err=" + e + ']'); cause.retryReadyFuture(cctx.nextAffinityReadyFuture(tx.topologyVersion())); "(transaction has been rolled back on backup node): " + tx.xidVersion(), cause)); cctx.io().send(backup, finishReq, tx.ioPolicy());
/** * Commit and properly close transaction. * @param tx Transaction. * @throws IgniteCheckedException if failed. */ private void doCommit(@NotNull GridNearTxLocal tx) throws IgniteCheckedException { try { // TODO: Why checking for rollback only? //if (!tx.isRollbackOnly()) tx.commit(); } finally { closeTx(tx); } }
/** {@inheritDoc} */ @Override public final T apply(T t, @Nullable Exception e) { boolean rollback = true; try { if (e != null) throw new GridClosureException(e); t = finish(t); // Commit implicit transactions. if (implicit()) commit(); rollback = false; return t; } catch (IgniteCheckedException ex) { throw new GridClosureException(ex); } finally { if (rollback) setRollbackOnly(); } }
/** {@inheritDoc} */ @Override public int prepare(Xid xid) throws XAException { assert this.xid.equals(xid); if (log.isDebugEnabled()) log.debug("XA resource prepare(...) [xid=" + xid + "]"); if (cacheTx.state() != ACTIVE) throw new XAException("Cache transaction is not in active state."); try { cacheTx.prepare(true); } catch (IgniteCheckedException e) { throwException("Failed to prepare cache transaction.", e); } return XA_OK; }
if (fut0 != null || !FINISH_FUT_UPD.compareAndSet(this, null, fut = finishFuture(fastFinish = fastFinish(), true))) return chainFinishFuture(finishFut, true, true, false); final IgniteInternalFuture<?> prepareFut = prepareNearTxLocal();