Skip to content

Commit

Permalink
2.1 More simple tx cancel on node stop
Browse files Browse the repository at this point in the history
  • Loading branch information
sboikov committed Jul 7, 2017
1 parent 31e9d3b commit ab52671
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
Expand Up @@ -964,6 +964,8 @@ public void blockGateways() {
// No new caches should be added after this point.
exch.onKernalStop(cancel);

sharedCtx.mvcc().onStop();

for (CacheGroupContext grp : cacheGrps.values())
grp.onKernalStop();

Expand Down
Expand Up @@ -225,7 +225,9 @@ public void onResult(UUID nodeId, GridDhtTxFinishResponse res) {

if (this.tx.onePhaseCommit() && (this.tx.state() == COMMITTING)) {
try {
this.tx.tmFinish(err == null);
boolean nodeStop = err != null && X.hasCause(err, NodeStoppingException.class);

this.tx.tmFinish(err == null, nodeStop);
}
catch (IgniteCheckedException finishErr) {
U.error(log, "Failed to finish tx: " + tx, e);
Expand Down
Expand Up @@ -327,7 +327,7 @@ else if (err != null)
finishOnePhase(commit);

try {
tx.tmFinish(commit);
tx.tmFinish(commit, nodeStop);
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to finish tx: " + tx, e);
Expand All @@ -338,7 +338,7 @@ else if (err != null)
}

if (super.onDone(tx0, err)) {
if (error() instanceof IgniteTxHeuristicCheckedException) {
if (error() instanceof IgniteTxHeuristicCheckedException && !nodeStop) {
AffinityTopologyVersion topVer = tx.topologyVersion();

for (IgniteTxEntry e : tx.writeMap().values()) {
Expand Down
Expand Up @@ -435,9 +435,9 @@ protected void uncommit(boolean nodeStopping) {
break;
}
}
}

cctx.tm().uncommitTx(this);
cctx.tm().uncommitTx(this);
}
}
catch (Exception ex) {
U.error(log, "Failed to do uncommit.", ex);
Expand Down
Expand Up @@ -898,17 +898,20 @@ assert ownsLock(txEntry.cached()):
* Commits transaction to transaction manager. Used for one-phase commit transactions only.
*
* @param commit If {@code true} commits transaction, otherwise rollbacks.
* @param nodeStop If {@code true} tx is cancelled on node stop.
* @throws IgniteCheckedException If failed.
*/
public void tmFinish(boolean commit) throws IgniteCheckedException {
public void tmFinish(boolean commit, boolean nodeStop) throws IgniteCheckedException {
assert onePhaseCommit();

if (DONE_FLAG_UPD.compareAndSet(this, 0, 1)) {
// Unlock all locks.
if (commit)
cctx.tm().commitTx(this);
else
cctx.tm().rollbackTx(this);
if (!nodeStop) {
// Unlock all locks.
if (commit)
cctx.tm().commitTx(this);
else
cctx.tm().rollbackTx(this);
}

state(commit ? COMMITTED : ROLLED_BACK);

Expand Down

0 comments on commit ab52671

Please sign in to comment.