Repository: incubator-ignite Updated Branches: refs/heads/ignite-635 3be59d5af -> 67b5cb68e
IGNITE-477 - Fixed locking issue. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/92a7aad4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/92a7aad4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/92a7aad4 Branch: refs/heads/ignite-635 Commit: 92a7aad4ccf673d0161ce0f6d4d6b7025f67dd08 Parents: 580f051 Author: Alexey Goncharuk <agoncha...@gridgain.com> Authored: Fri Apr 3 17:30:20 2015 -0700 Committer: Alexey Goncharuk <agoncha...@gridgain.com> Committed: Fri Apr 3 17:30:20 2015 -0700 ---------------------------------------------------------------------- .../distributed/dht/GridDhtLockFuture.java | 10 +++- .../distributed/dht/GridDhtTxLocalAdapter.java | 49 +++++++++++--------- .../ignite/testsuites/IgniteCacheTestSuite.java | 3 +- 3 files changed, 38 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/92a7aad4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java index 7e93946..2c31a13 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java @@ -862,10 +862,18 @@ public final class GridDhtLockFuture<K, V> extends GridCompoundIdentityFuture<Bo invalidateRdr, cctx); - if (needVal) + if (needVal) { // Mark last added key as needed to be preloaded. req.markLastKeyForPreload(); + if (tx != null) { + IgniteTxEntry txEntry = tx.entry(e.txKey()); + + // NOOP entries will be sent to backups on prepare step. + txEntry.op(GridCacheOperation.NOOP); + } + } + it.set(addOwned(req, e)); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/92a7aad4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java index 5e37d96..54ceb36 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java @@ -444,46 +444,53 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter { GridDhtCacheAdapter dhtCache = cacheCtx.isNear() ? cacheCtx.near().dht() : cacheCtx.dht(); try { - IgniteTxEntry entry = txMap.get(e.txKey()); - - if (entry != null) { - entry.op(e.op()); // Absolutely must set operation, as default is DELETE. - entry.value(e.value(), e.hasWriteValue(), e.hasReadValue()); - entry.entryProcessors(e.entryProcessors()); - entry.ttl(e.ttl()); - entry.filters(e.filters()); - entry.expiry(e.expiry()); - - entry.conflictExpireTime(e.conflictExpireTime()); - entry.conflictVersion(e.conflictVersion()); + IgniteTxEntry existing = txMap.get(e.txKey()); + + if (existing != null) { + // Must keep NOOP operation if received READ because it means that the lock was sent to a backup node. + if (e.op() == READ) { + if (existing.op() != NOOP) + existing.op(e.op()); + } + else + existing.op(e.op()); // Absolutely must set operation, as default is DELETE. + + existing.value(e.value(), e.hasWriteValue(), e.hasReadValue()); + existing.entryProcessors(e.entryProcessors()); + existing.ttl(e.ttl()); + existing.filters(e.filters()); + existing.expiry(e.expiry()); + + existing.conflictExpireTime(e.conflictExpireTime()); + existing.conflictVersion(e.conflictVersion()); } else { - entry = e; + existing = e; addActiveCache(dhtCache.context()); - GridDhtCacheEntry cached = dhtCache.entryExx(entry.key(), topologyVersion()); + GridDhtCacheEntry cached = dhtCache.entryExx(existing.key(), topologyVersion()); - entry.cached(cached); + existing.cached(cached); - GridCacheVersion explicit = entry.explicitVersion(); + GridCacheVersion explicit = existing.explicitVersion(); if (explicit != null) { GridCacheVersion dhtVer = cctx.mvcc().mappedVersion(explicit); if (dhtVer == null) - throw new IgniteCheckedException("Failed to find dht mapping for explicit entry version: " + entry); + throw new IgniteCheckedException("Failed to find dht mapping for explicit entry version: " + existing); - entry.explicitVersion(dhtVer); + existing.explicitVersion(dhtVer); } - txMap.put(entry.txKey(), entry); + txMap.put(existing.txKey(), existing); if (log.isDebugEnabled()) - log.debug("Added entry to transaction: " + entry); + log.debug("Added entry to transaction: " + existing); } - return addReader(msgId, dhtCache.entryExx(entry.key()), entry, topologyVersion()); + return addReader(msgId, dhtCache.entryExx(existing.key()), existing, topologyVersion()); } catch (GridDhtInvalidPartitionException ex) { addInvalidPartition(cacheCtx, ex.partition()); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/92a7aad4/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java index d5ae2e6..f90ab72 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java @@ -406,8 +406,7 @@ public class IgniteCacheTestSuite extends TestSuite { suite.addTestSuite(IgniteCacheAtomicCopyOnReadDisabledTest.class); suite.addTestSuite(IgniteCacheTxCopyOnReadDisabledTest.class); - // TODO: IGNITE-477. - // suite.addTestSuite(IgniteCacheTxPreloadNoWriteTest.class); + suite.addTestSuite(IgniteCacheTxPreloadNoWriteTest.class); suite.addTestSuite(IgniteDynamicCacheStartSelfTest.class); suite.addTestSuite(IgniteCacheDynamicStopSelfTest.class);