ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [19/47] ignite git commit: IGNITE-4767: rollback exception hides the origin exception (e.g. commit): Suppressing or logging rollback exceptions instead of hiding the origin exception Fixes #1599
Date Tue, 01 Aug 2017 09:26:02 GMT
IGNITE-4767: rollback exception hides the origin exception (e.g. commit): Suppressing or logging
rollback exceptions instead of hiding the origin exception
Fixes #1599


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

Branch: refs/heads/master
Commit: a07d7b91d148df8dfd7c4bbad2a63f8dea97b036
Parents: be5a9ea
Author: Alexandr Kuramshin <ein.nsk.ru@gmail.com>
Authored: Thu Jul 27 15:04:42 2017 +0300
Committer: dpavlov <dpavlov@gridgain.com>
Committed: Thu Jul 27 15:05:16 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheAdapter.java      | 16 ++++--
 .../dht/GridDhtTransactionalCacheAdapter.java   |  7 ++-
 .../distributed/dht/GridDhtTxPrepareFuture.java | 24 +++++++--
 .../cache/transactions/IgniteTxHandler.java     | 51 +++++++++++++++-----
 .../cache/transactions/IgniteTxManager.java     |  7 ++-
 .../apache/ignite/stream/flume/IgniteSink.java  |  7 ++-
 6 files changed, 91 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a07d7b91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 9213be3..4ba4e48 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -4072,7 +4072,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K,
V
                         catch (IgniteCheckedException | AssertionError | RuntimeException
e1) {
                             U.error(log, "Failed to rollback transaction (cache may contain
stale locks): " + tx, e1);
 
-                            U.addLastCause(e, e1, log);
+                            e.addSuppressed(e1);
                         }
                     }
 
@@ -4205,7 +4205,12 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K,
V
                                         throw e;
                                     }
                                     catch (IgniteCheckedException e1) {
-                                        tx0.rollbackNearTxLocalAsync();
+                                        try {
+                                            tx0.rollbackNearTxLocalAsync();
+                                        }
+                                        catch (Throwable e2) {
+                                            e1.addSuppressed(e2);
+                                        }
 
                                         throw e1;
                                     }
@@ -4231,7 +4236,12 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K,
V
                         throw e;
                     }
                     catch (IgniteCheckedException e1) {
-                        tx0.rollbackNearTxLocalAsync();
+                        try {
+                            tx0.rollbackNearTxLocalAsync();
+                        }
+                        catch (Throwable e2) {
+                            e1.addSuppressed(e2);
+                        }
 
                         throw e1;
                     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a07d7b91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
index 73942ff..063986f9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
@@ -1338,7 +1338,12 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V>
extends GridDhtCach
                 ", res=" + res + ']', e);
 
             if (tx != null)
-                tx.rollbackDhtLocalAsync();
+                try {
+                    tx.rollbackDhtLocalAsync();
+                }
+                catch (Throwable e1) {
+                    e.addSuppressed(e1);
+                }
 
             // Convert to closure exception as this method is only called form closures.
             throw new GridClosureException(e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a07d7b91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index 6ed4781..a31c540 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -736,16 +736,27 @@ public final class GridDhtTxPrepareFuture extends GridCacheCompoundFuture<Ignite
 
                             tx.systemInvalidate(true);
 
-                            fut = tx.rollbackAsync();
+                            try {
+                                fut = tx.rollbackAsync();
 
-                            fut.listen(resClo);
+                                fut.listen(resClo);
+                            }
+                            catch (Throwable e1) {
+                                e.addSuppressed(e1);
+                            }
 
                             throw e;
                         }
 
                     }
                     else if (!cctx.kernalContext().isStopping())
-                        fut = tx.rollbackAsync();
+                        try {
+                            fut = tx.rollbackAsync();
+                        }
+                        catch (Throwable e) {
+                            err.addSuppressed(e);
+                            fut = null;
+                        }
 
                     if (fut != null)
                         fut.listen(resClo);
@@ -1199,7 +1210,12 @@ public final class GridDhtTxPrepareFuture extends GridCacheCompoundFuture<Ignite
                 if (err0 != null) {
                     ERR_UPD.compareAndSet(this, null, err0);
 
-                    tx.rollbackAsync();
+                    try {
+                        tx.rollbackAsync();
+                    }
+                    catch (Throwable e) {
+                        err0.addSuppressed(e);
+                    }
 
                     final GridNearTxPrepareResponse res = createPrepareResponse(err);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a07d7b91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
index c473bfe..b7ff319 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
@@ -863,14 +863,17 @@ public class IgniteTxHandler {
 
             U.error(log, "Failed completing transaction [commit=" + req.commit() + ", tx="
+ tx + ']', e);
 
-            IgniteInternalFuture<IgniteInternalTx> res;
+            IgniteInternalFuture<IgniteInternalTx> res = null;
 
-            IgniteInternalFuture<IgniteInternalTx> rollbackFut = tx.rollbackDhtLocalAsync();
-
-            // Only for error logging.
-            rollbackFut.listen(CU.errorLogger(log));
+            try {
+                res = tx.rollbackDhtLocalAsync();
 
-            res = rollbackFut;
+                // Only for error logging.
+                res.listen(CU.errorLogger(log));
+            }
+            catch (Throwable e1) {
+                e.addSuppressed(e1);
+            }
 
             if (e instanceof Error)
                 throw (Error)e;
@@ -906,7 +909,12 @@ public class IgniteTxHandler {
                 throw e;
 
             if (tx != null)
-                return tx.rollbackNearTxLocalAsync();
+                try {
+                    return tx.rollbackNearTxLocalAsync();
+                }
+                catch (Throwable e1) {
+                    e.addSuppressed(e1);
+                }
 
             return new GridFinishedFuture<>(e);
         }
@@ -1000,7 +1008,12 @@ public class IgniteTxHandler {
                 U.error(log, "Failed to process prepare request: " + req, e);
 
             if (nearTx != null)
-                nearTx.rollbackRemoteTx();
+                try {
+                    nearTx.rollbackRemoteTx();
+                }
+                catch (Throwable e1) {
+                    e.addSuppressed(e1);
+                }
 
             res = new GridDhtTxPrepareResponse(
                 req.partition(),
@@ -1261,7 +1274,13 @@ public class IgniteTxHandler {
             tx.invalidate(true);
             tx.systemInvalidate(true);
 
-            tx.rollbackRemoteTx();
+            try {
+                tx.rollbackRemoteTx();
+            }
+            catch (Throwable e1) {
+                e.addSuppressed(e1);
+                U.error(log, "Failed to automatically rollback transaction: " + tx, e1);
+            }
 
             if (e instanceof Error)
                 throw (Error)e;
@@ -1307,10 +1326,20 @@ public class IgniteTxHandler {
             }
 
             if (nearTx != null)
-                nearTx.rollbackRemoteTx();
+                try {
+                    nearTx.rollbackRemoteTx();
+                }
+                catch (Throwable e1) {
+                    e.addSuppressed(e1);
+                }
 
             if (dhtTx != null)
-                dhtTx.rollbackRemoteTx();
+                try {
+                    dhtTx.rollbackRemoteTx();
+                }
+                catch (Throwable e1) {
+                    e.addSuppressed(e1);
+                }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a07d7b91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index 26a4a91..7d612ec 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -2422,7 +2422,12 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter
{
                     log.debug("Optimistic failure while committing prepared transaction (will
rollback): " +
                         tx);
 
-                tx.rollbackAsync();
+                try {
+                    tx.rollbackAsync();
+                }
+                catch (Throwable e) {
+                    U.error(log, "Failed to automatically rollback transaction: " + tx, e);
+                }
             }
             catch (IgniteCheckedException e) {
                 U.error(log, "Failed to commit transaction during failover: " + tx, e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a07d7b91/modules/flume/src/main/java/org/apache/ignite/stream/flume/IgniteSink.java
----------------------------------------------------------------------
diff --git a/modules/flume/src/main/java/org/apache/ignite/stream/flume/IgniteSink.java b/modules/flume/src/main/java/org/apache/ignite/stream/flume/IgniteSink.java
index 083e833..64559ef 100644
--- a/modules/flume/src/main/java/org/apache/ignite/stream/flume/IgniteSink.java
+++ b/modules/flume/src/main/java/org/apache/ignite/stream/flume/IgniteSink.java
@@ -178,7 +178,12 @@ public class IgniteSink extends AbstractSink implements Configurable
{
         catch (Exception e) {
             log.error("Failed to process events", e);
 
-            transaction.rollback();
+            try {
+                transaction.rollback();
+            }
+            catch (Throwable e1) {
+                e.addSuppressed(e1);
+            }
 
             throw new EventDeliveryException(e);
         }


Mime
View raw message