/** * Checks if mapped transaction can be committed on one phase. * One-phase commit can be done if transaction maps to one primary node and not more than one backup. * * @param txNodes Primary to backups node map. */ final void checkOnePhase(Map<UUID, Collection<UUID>> txNodes) { if (tx.storeWriteThrough() || tx.txState().mvccEnabled()) // TODO IGNITE-3479 (onePhase + mvcc) return; if (txNodes.size() == 1) { Map.Entry<UUID, Collection<UUID>> entry = txNodes.entrySet().iterator().next(); assert entry != null; Collection<UUID> backups = entry.getValue(); if (backups.size() <= 1) tx.onePhaseCommit(true); } }
/** {@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; }
/** * @param commit Commit flag. * @return {@code True} if need to send finish request for one phase commit transaction. */ private boolean needFinishOnePhase(boolean commit) { assert tx.onePhaseCommit(); if (tx.mappings().empty()) return false; if (!commit) return true; GridDistributedTxMapping mapping = tx.mappings().singleMapping(); assert mapping != null; return mapping.hasNearCacheEntries(); }
/** * @param m Failed mapping. * @param e Error. */ private void onError(@Nullable GridDistributedTxMapping m, Throwable e) { if (X.hasCause(e, ClusterTopologyCheckedException.class) || X.hasCause(e, ClusterTopologyException.class)) { if (tx.onePhaseCommit()) { tx.markForBackupCheck(); onComplete(); return; } } if (e instanceof IgniteTxOptimisticCheckedException) { if (m != null) tx.removeMapping(m.primary().id()); } prepareError(e); }
/** * @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 finish(final boolean commit, final boolean clearThreadMap, final boolean onTimeout) { if (!cctx.mvcc().addFuture(this, futureId())) return; if (tx.onNeedCheckBackup()) { assert tx.onePhaseCommit(); checkBackup(); // If checkBackup is set, it means that primary node has crashed and we will not need to send // finish request to it, so we can mark future as initialized. markInitialized(); return; } if (!commit && !clearThreadMap) rollbackAsyncSafe(onTimeout); else doFinish(commit, clearThreadMap); }
/** * Completeness callback. * * @return {@code True} if future was finished by this call. */ private boolean onComplete() { Throwable err0 = err; if ((!tx.onePhaseCommit() || tx.mappings().get(cctx.localNodeId()) == null) && (err0 == null || tx.needCheckBackup())) tx.state(PREPARED); if (super.onDone(tx, err0)) { // Don't forget to clean up. cctx.mvcc().removeVersionedFuture(this); return true; } return false; }
if (tx.onePhaseCommit()) { tx.markForBackupCheck();
/** * Completeness callback. * * @return {@code True} if future was finished by this call. */ private boolean onComplete() { Throwable err0 = err; if ((!tx.onePhaseCommit() || tx.mappings().get(cctx.localNodeId()) == null) && (err0 == null || tx.needCheckBackup())) tx.state(PREPARED); if (super.onDone(tx, err0)) { if (err0 != null) tx.setRollbackOnly(); // Don't forget to clean up. cctx.mvcc().removeVersionedFuture(this); return true; } return false; }
cctx.tm().rollbackTx(tx, clearThreadMap, false); if ((tx.onePhaseCommit() && needFinishOnePhase(commit)) || (!tx.onePhaseCommit() && mappings != null)) { if (mappings.single()) { GridDistributedTxMapping mapping = mappings.singleMapping(); tx.onePhaseCommit() &&
assert tx.onePhaseCommit(); if (tx.onePhaseCommit()) { boolean commit = this.commit && err == null;
txNodes, m.last(), tx.onePhaseCommit(), tx.needReturnValue() && tx.implicit(), tx.implicitSingle(),
if (tx.onePhaseCommit() && !res.onePhaseCommit()) tx.onePhaseCommit(false);
txNodes, true, tx.onePhaseCommit(), tx.needReturnValue() && tx.implicit(), tx.implicitSingle(),
if (!onePhaseCommit()) { if (!state(COMMITTED)) { state(UNKNOWN);
res.rolledbackVersions(), res.pending()); if (inTx() && implicitTx() && tx.onePhaseCommit()) { boolean pass = res.filterResult(i);
tx.hasRemoteLocks(true); if (implicitTx() && tx.onePhaseCommit()) { boolean pass = res.filterResult(i);
txMapping.transactionNodes(), m.last(), tx.onePhaseCommit(), tx.needReturnValue() && tx.implicit(), tx.implicitSingle(),
/** * @param commit Commit flag. * @return {@code True} if need to send finish request for one phase commit transaction. */ private boolean needFinishOnePhase(boolean commit) { assert tx.onePhaseCommit(); if (tx.mappings().empty()) return false; if (!commit) return true; GridDistributedTxMapping mapping = tx.mappings().singleMapping(); assert mapping != null; return mapping.hasNearCacheEntries(); }
/** * @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); }