You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2017/07/07 09:34:42 UTC
[39/46] ignite git commit: 2.1 Do print stack traces if tx is
cancelled on node stop
2.1 Do print stack traces if tx is cancelled on node stop
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2f1270ee
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2f1270ee
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2f1270ee
Branch: refs/heads/ignite-2.1
Commit: 2f1270ee9b3edf8c50562e33275dfbd3807d608a
Parents: c396b0b
Author: sboikov <sb...@gridgain.com>
Authored: Thu Jul 6 14:53:25 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Jul 6 14:53:25 2017 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheEntryEx.java | 14 +----
.../processors/cache/GridCacheMapEntry.java | 54 +++-----------------
.../GridDistributedTxRemoteAdapter.java | 13 ++++-
.../dht/GridDhtTransactionalCacheAdapter.java | 2 +-
.../near/GridNearTxFinishFuture.java | 2 +-
.../cache/transactions/IgniteTxAdapter.java | 28 +++++-----
.../cache/transactions/IgniteTxHandler.java | 2 +-
.../transactions/IgniteTxLocalAdapter.java | 12 ++++-
.../processors/cache/GridCacheTestEntryEx.java | 10 +---
9 files changed, 48 insertions(+), 89 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2f1270ee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
index 4e52680..b708b43 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
@@ -192,23 +192,11 @@ public interface GridCacheEntryEx {
/**
* Invalidates this entry.
*
- * @param curVer Current version to match ({@code null} means always match).
* @param newVer New version to set.
* @return {@code true} if entry is obsolete.
* @throws IgniteCheckedException If swap could not be released.
*/
- public boolean invalidate(@Nullable GridCacheVersion curVer, GridCacheVersion newVer) throws IgniteCheckedException;
-
- /**
- * Invalidates this entry if it passes given filter.
- *
- * @param filter Optional filter that entry should pass before invalidation.
- * @return {@code true} if entry was actually invalidated.
- * @throws IgniteCheckedException If swap could not be released.
- * @throws GridCacheEntryRemovedException If entry was removed.
- */
- public boolean invalidate(@Nullable CacheEntryPredicate[] filter)
- throws GridCacheEntryRemovedException, IgniteCheckedException;
+ public boolean invalidate(GridCacheVersion newVer) throws IgniteCheckedException;
/**
* @param obsoleteVer Version for eviction.
http://git-wip-us.apache.org/repos/asf/ignite/blob/2f1270ee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index eea8935..14bd1c5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -2226,20 +2226,18 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
/** {@inheritDoc} */
- @Override public synchronized boolean invalidate(@Nullable GridCacheVersion curVer, GridCacheVersion newVer)
+ @Override public synchronized boolean invalidate(GridCacheVersion newVer)
throws IgniteCheckedException {
assert newVer != null;
- if (curVer == null || ver.equals(curVer)) {
- value(null);
+ value(null);
- ver = newVer;
- flags &= ~IS_EVICT_DISABLED;
+ ver = newVer;
+ flags &= ~IS_EVICT_DISABLED;
- removeValue();
+ removeValue();
- onInvalidate();
- }
+ onInvalidate();
return obsoleteVersionExtras() != null;
}
@@ -2251,46 +2249,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
// No-op.
}
- /** {@inheritDoc} */
- @Override public boolean invalidate(@Nullable CacheEntryPredicate[] filter)
- throws GridCacheEntryRemovedException, IgniteCheckedException {
- if (F.isEmptyOrNulls(filter)) {
- synchronized (this) {
- checkObsolete();
-
- invalidate(null, nextVersion());
-
- return true;
- }
- }
- else {
- // For optimistic checking.
- GridCacheVersion startVer;
-
- synchronized (this) {
- checkObsolete();
-
- startVer = ver;
- }
-
- if (!cctx.isAll(this, filter))
- return false;
-
- synchronized (this) {
- checkObsolete();
-
- if (startVer.equals(ver)) {
- invalidate(null, nextVersion());
-
- return true;
- }
- }
-
- // If version has changed then repeat the process.
- return invalidate(filter);
- }
- }
-
/**
* @param val New value.
* @param expireTime Expiration time.
http://git-wip-us.apache.org/repos/asf/ignite/blob/2f1270ee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
index 5e3020d..ea6461d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
@@ -29,6 +29,7 @@ import java.util.UUID;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.NodeStoppingException;
import org.apache.ignite.internal.pagemem.wal.StorageException;
import org.apache.ignite.internal.pagemem.wal.WALPointer;
import org.apache.ignite.internal.pagemem.wal.record.DataEntry;
@@ -61,6 +62,7 @@ import org.apache.ignite.internal.util.lang.GridTuple;
import org.apache.ignite.internal.util.tostring.GridToStringBuilder;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
@@ -716,14 +718,21 @@ public abstract class GridDistributedTxRemoteAdapter extends IgniteTxAdapter
}
}
catch (Throwable ex) {
+ boolean nodeStopping = X.hasCause(ex, NodeStoppingException.class);
+
// In case of error, we still make the best effort to commit,
// as there is no way to rollback at this point.
err = new IgniteTxHeuristicCheckedException("Commit produced a runtime exception " +
"(all transaction entries will be invalidated): " + CU.txString(this), ex);
- U.error(log, "Commit failed.", err);
+ if (nodeStopping) {
+ U.warn(log, "Failed to commit transaction, node is stopping [tx=" + this +
+ ", err=" + ex + ']');
+ }
+ else
+ U.error(log, "Commit failed.", err);
- uncommit();
+ uncommit(nodeStopping);
state(UNKNOWN);
http://git-wip-us.apache.org/repos/asf/ignite/blob/2f1270ee/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 5d31581..73942ff 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
@@ -1700,7 +1700,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
GridCacheEntryEx nearEntry = near().peekEx(key);
if (nearEntry != null)
- nearEntry.invalidate(null, ver);
+ nearEntry.invalidate(ver);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/2f1270ee/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 27cebf8..7f6f793 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
@@ -349,7 +349,7 @@ public final class GridNearTxFinishFuture<K, V> extends GridCacheCompoundIdentit
GridCacheEntryEx entry = cacheCtx.cache().peekEx(e.key());
if (entry != null)
- entry.invalidate(null, tx.xidVersion());
+ entry.invalidate(tx.xidVersion());
}
}
catch (Throwable t) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/2f1270ee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
index ee8afb0..51956ac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
@@ -412,24 +412,28 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
/**
* Uncommits transaction by invalidating all of its entries. Courtesy to minimize inconsistency.
+ *
+ * @param nodeStopping {@code True} if tx was cancelled during node stop.
*/
@SuppressWarnings({"CatchGenericClass"})
- protected void uncommit() {
+ protected void uncommit(boolean nodeStopping) {
try {
- for (IgniteTxEntry e : writeMap().values()) {
- try {
- GridCacheEntryEx Entry = e.cached();
+ if (!nodeStopping) {
+ for (IgniteTxEntry e : writeMap().values()) {
+ try {
+ GridCacheEntryEx entry = e.cached();
- if (e.op() != NOOP)
- Entry.invalidate(null, xidVer);
- }
- catch (Throwable t) {
- U.error(log, "Failed to invalidate transaction entries while reverting a commit.", t);
+ if (e.op() != NOOP)
+ entry.invalidate(xidVer);
+ }
+ catch (Throwable t) {
+ U.error(log, "Failed to invalidate transaction entries while reverting a commit.", t);
- if (t instanceof Error)
- throw (Error)t;
+ if (t instanceof Error)
+ throw (Error)t;
- break;
+ break;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2f1270ee/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 7efd6ec..c473bfe 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
@@ -1595,7 +1595,7 @@ public class IgniteTxHandler {
GridCacheEntryEx nearEntry = near.peekEx(key);
if (nearEntry != null)
- nearEntry.invalidate(null, ver);
+ nearEntry.invalidate(ver);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/2f1270ee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index e4b850d..49b67da 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -32,6 +32,7 @@ import javax.cache.processor.EntryProcessor;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.NodeStoppingException;
import org.apache.ignite.internal.pagemem.wal.StorageException;
import org.apache.ignite.internal.pagemem.wal.WALPointer;
import org.apache.ignite.internal.pagemem.wal.record.DataEntry;
@@ -828,11 +829,18 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
throw ex;
}
else {
+ boolean nodeStopping = X.hasCause(ex, NodeStoppingException.class);
+
IgniteCheckedException err = new IgniteTxHeuristicCheckedException("Failed to locally write to cache " +
"(all transaction entries will be invalidated, however there was a window when " +
"entries for this transaction were visible to others): " + this, ex);
- U.error(log, "Heuristic transaction failure.", err);
+ if (nodeStopping) {
+ U.warn(log, "Failed to commit transaction, node is stopping " +
+ "[tx=" + this + ", err=" + ex + ']');
+ }
+ else
+ U.error(log, "Heuristic transaction failure.", err);
COMMIT_ERR_UPD.compareAndSet(this, null, err);
@@ -840,7 +848,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
try {
// Courtesy to minimize damage.
- uncommit();
+ uncommit(nodeStopping);
}
catch (Throwable ex1) {
U.error(log, "Failed to uncommit transaction: " + this, ex1);
http://git-wip-us.apache.org/repos/asf/ignite/blob/2f1270ee/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
index a6c9cd4..0241165 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
@@ -353,7 +353,7 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
}
/** @inheritDoc */
- @Override public boolean invalidate(@Nullable GridCacheVersion curVer, GridCacheVersion newVer)
+ @Override public boolean invalidate(GridCacheVersion newVer)
throws IgniteCheckedException {
assert false;
@@ -361,14 +361,6 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
}
/** @inheritDoc */
- @Override public boolean invalidate(@Nullable CacheEntryPredicate[] filter)
- throws GridCacheEntryRemovedException, IgniteCheckedException {
- assert false;
-
- return false;
- }
-
- /** @inheritDoc */
@Override public boolean evictInternal(GridCacheVersion obsoleteVer,
@Nullable CacheEntryPredicate[] filter, boolean evictOffheap) {
assert false;