You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by nt...@apache.org on 2016/02/01 15:27:10 UTC

[15/48] ignite git commit: IGNITE-2453 Fixed single primary and single backup failure cause NPE at future for backup - Fixes #427.

IGNITE-2453 Fixed single primary and single backup failure cause NPE at future for backup - Fixes #427.

Signed-off-by: Alexey Goncharuk <al...@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/579d33a0
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/579d33a0
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/579d33a0

Branch: refs/heads/ignite-2454
Commit: 579d33a0913a0acecab02b754dca4e4ff4c87ea7
Parents: 550a4ea
Author: vershov <ve...@gridgain.com>
Authored: Thu Jan 28 12:29:31 2016 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Thu Jan 28 12:29:31 2016 +0300

----------------------------------------------------------------------
 .../near/GridNearTxFinishFuture.java            | 96 ++++++++++----------
 1 file changed, 49 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/579d33a0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
index 3c33bc4..078e322 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
@@ -418,10 +418,6 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
 
                 ClusterNode backup = cctx.discovery().node(backupId);
 
-                final CheckBackupMiniFuture mini = new CheckBackupMiniFuture(backup, mapping);
-
-                add(mini);
-
                 // Nothing to do if backup has left the grid.
                 if (backup == null) {
                     readyNearMappingFromBackup(mapping);
@@ -431,64 +427,70 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
 
                     cause.retryReadyFuture(cctx.nextAffinityReadyFuture(tx.topologyVersion()));
 
-                    mini.onDone(new IgniteTxRollbackCheckedException("Failed to commit transaction " +
+                    onDone(new IgniteTxRollbackCheckedException("Failed to commit transaction " +
                         "(backup has left grid): " + tx.xidVersion(), cause));
                 }
-                else if (backup.isLocal()) {
-                    boolean committed = !cctx.tm().addRolledbackTx(tx);
+                else {
+                    final CheckBackupMiniFuture mini = new CheckBackupMiniFuture(backup, mapping);
 
-                    readyNearMappingFromBackup(mapping);
+                    add(mini);
 
-                    if (committed) {
-                        if (tx.syncCommit()) {
-                            GridCacheVersion nearXidVer = tx.nearXidVersion();
+                    if (backup.isLocal()) {
+                        boolean committed = !cctx.tm().addRolledbackTx(tx);
 
-                            assert nearXidVer != null : tx;
+                        readyNearMappingFromBackup(mapping);
 
-                            IgniteInternalFuture<?> fut = cctx.tm().remoteTxFinishFuture(nearXidVer);
+                        if (committed) {
+                            if (tx.syncCommit()) {
+                                GridCacheVersion nearXidVer = tx.nearXidVersion();
 
-                            fut.listen(new CI1<IgniteInternalFuture<?>>() {
-                                @Override public void apply(IgniteInternalFuture<?> fut) {
-                                    mini.onDone(tx);
-                                }
-                            });
+                                assert nearXidVer != null : tx;
 
-                            return;
-                        }
+                                IgniteInternalFuture<?> fut = cctx.tm().remoteTxFinishFuture(nearXidVer);
 
-                        mini.onDone(tx);
-                    }
-                    else {
-                        ClusterTopologyCheckedException cause =
-                            new ClusterTopologyCheckedException("Primary node left grid: " + nodeId);
+                                fut.listen(new CI1<IgniteInternalFuture<?>>() {
+                                    @Override public void apply(IgniteInternalFuture<?> fut) {
+                                        mini.onDone(tx);
+                                    }
+                                });
 
-                        cause.retryReadyFuture(cctx.nextAffinityReadyFuture(tx.topologyVersion()));
+                                return;
+                            }
 
-                        mini.onDone(new IgniteTxRollbackCheckedException("Failed to commit transaction " +
-                            "(transaction has been rolled back on backup node): " + tx.xidVersion(), cause));
-                    }
-                }
-                else {
-                    GridDhtTxFinishRequest finishReq = checkCommittedRequest(mini.futureId());
+                            mini.onDone(tx);
+                        }
+                        else {
+                            ClusterTopologyCheckedException cause =
+                                new ClusterTopologyCheckedException("Primary node left grid: " + nodeId);
 
-                    // Preserve old behavior, otherwise response is not sent.
-                    if (WAIT_REMOTE_TXS_SINCE.compareTo(backup.version()) > 0)
-                        finishReq.syncCommit(true);
+                            cause.retryReadyFuture(cctx.nextAffinityReadyFuture(tx.topologyVersion()));
 
-                    try {
-                        if (FINISH_NEAR_ONE_PHASE_SINCE.compareTo(backup.version()) <= 0)
-                            cctx.io().send(backup, finishReq, tx.ioPolicy());
-                        else {
-                            mini.onDone(new IgniteTxHeuristicCheckedException("Failed to check for tx commit on " +
-                                "the backup node (node has an old Ignite version) [rmtNodeId=" + backup.id() +
-                                ", ver=" + backup.version() + ']'));
+                            mini.onDone(new IgniteTxRollbackCheckedException("Failed to commit transaction " +
+                                "(transaction has been rolled back on backup node): " + tx.xidVersion(), cause));
                         }
                     }
-                    catch (ClusterTopologyCheckedException e) {
-                        mini.onNodeLeft(backupId);
-                    }
-                    catch (IgniteCheckedException e) {
-                        mini.onDone(e);
+                    else {
+                        GridDhtTxFinishRequest finishReq = checkCommittedRequest(mini.futureId());
+
+                        // Preserve old behavior, otherwise response is not sent.
+                        if (WAIT_REMOTE_TXS_SINCE.compareTo(backup.version()) > 0)
+                            finishReq.syncCommit(true);
+
+                        try {
+                            if (FINISH_NEAR_ONE_PHASE_SINCE.compareTo(backup.version()) <= 0)
+                                cctx.io().send(backup, finishReq, tx.ioPolicy());
+                            else {
+                                mini.onDone(new IgniteTxHeuristicCheckedException("Failed to check for tx commit on " +
+                                    "the backup node (node has an old Ignite version) [rmtNodeId=" + backup.id() +
+                                    ", ver=" + backup.version() + ']'));
+                            }
+                        }
+                        catch (ClusterTopologyCheckedException e) {
+                            mini.onNodeLeft(backupId);
+                        }
+                        catch (IgniteCheckedException e) {
+                            mini.onDone(e);
+                        }
                     }
                 }
             }