This is an automated email from the ASF dual-hosted git repository. av pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push: new b53bd5549df IGNITE-21368 MVCC code removal from transactional classes (#11203) b53bd5549df is described below commit b53bd5549df38fc9fab80fed5c1a77baa2f864bd Author: Ilya Shishkov <shishkovi...@gmail.com> AuthorDate: Wed Feb 7 19:25:13 2024 +0300 IGNITE-21368 MVCC code removal from transactional classes (#11203) --- .../processors/cache/GridCacheAdapter.java | 3 - .../GridDistributedTxRemoteAdapter.java | 4 +- .../dht/GridDhtTransactionalCacheAdapter.java | 27 +- .../distributed/dht/GridDhtTxFinishFuture.java | 19 +- .../distributed/dht/GridDhtTxLocalAdapter.java | 10 - .../distributed/dht/GridDhtTxPrepareFuture.java | 11 +- .../dht/NearTxQueryEnlistResultHandler.java | 4 +- .../near/GridNearTxAbstractEnlistFuture.java | 8 - .../distributed/near/GridNearTxEnlistFuture.java | 11 +- .../distributed/near/GridNearTxFinishFuture.java | 2 +- .../cache/distributed/near/GridNearTxLocal.java | 439 +-------------------- .../near/GridNearTxQueryEnlistFuture.java | 4 +- .../near/GridNearTxQueryResultsEnlistFuture.java | 11 +- .../GridNearReadRepairAbstractFuture.java | 2 +- .../internal/processors/cache/mvcc/MvccUtils.java | 29 +- .../cache/query/IgniteQueryErrorCode.java | 4 - .../cache/transactions/IgniteInternalTx.java | 11 - .../cache/transactions/IgniteTransactionsImpl.java | 1 - .../cache/transactions/IgniteTxAdapter.java | 17 - .../cache/transactions/IgniteTxHandler.java | 8 +- .../cache/transactions/IgniteTxLocalAdapter.java | 12 +- .../cache/transactions/IgniteTxManager.java | 2 - .../internal/processors/odbc/SqlListenerUtils.java | 3 - .../platform/client/tx/ClientTxStartRequest.java | 1 - .../TransactionMixedModeException.java | 35 -- .../main/resources/META-INF/classnames.properties | 1 - .../TxDataConsistencyOnCommitFailureTest.java | 9 +- .../processors/query/h2/IgniteH2Indexing.java | 337 ++++------------ .../processors/cache/jta/CacheJtaManager.java | 1 - 29 files changed, 105 insertions(+), 921 deletions(-) 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 789bbc11a1d..f35f32ee2dd 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 @@ -3683,7 +3683,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V READ_COMMITTED, tCfg.getDefaultTxTimeout(), !ctx.skipStore(), - false, 0, null ); @@ -3801,7 +3800,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V READ_COMMITTED, txCfg.getDefaultTxTimeout(), !skipStore, - false, 0, null); @@ -4821,7 +4819,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V READ_COMMITTED, CU.transactionConfiguration(ctx, ctx.kernalContext().config()).getDefaultTxTimeout(), opCtx == null || !opCtx.skipStore(), - false, 0, null); 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 8599b7e4f7c..5754a89d978 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 @@ -459,7 +459,7 @@ public abstract class GridDistributedTxRemoteAdapter extends IgniteTxAdapter imp GridCacheReturnCompletableWrapper wrapper = null; - if (!F.isEmpty(writeMap) || mvccSnapshot != null) { + if (!F.isEmpty(writeMap)) { GridCacheReturn ret = null; if (!near() && !local() && onePhaseCommit()) { @@ -490,8 +490,6 @@ public abstract class GridDistributedTxRemoteAdapter extends IgniteTxAdapter imp Set<GridDhtLocalPartition> reservedParts = new HashSet<>(); try { - assert mvccSnapshot == null; - Collection<IgniteTxEntry> entries = near() ? allEntries() : writeEntries(); // Data entry to write to WAL. 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 86cf0850114..e25fff47960 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 @@ -73,8 +73,6 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxQu import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxQueryResultsEnlistResponse; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxRemote; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearUnlockRequest; -import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot; -import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshotWithoutTxs; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalEx; @@ -102,7 +100,6 @@ import org.jetbrains.annotations.Nullable; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.internal.processors.cache.GridCacheOperation.NOOP; import static org.apache.ignite.internal.processors.cache.GridCacheUtils.isNearEnabled; -import static org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.MVCC_OP_COUNTER_NA; import static org.apache.ignite.internal.processors.security.SecurityUtils.securitySubjectId; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; @@ -682,8 +679,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach req.topologyVersion(), req.threadId(), req.txTimeout(), - req.taskNameHash(), - req.mvccSnapshot()); + req.taskNameHash()); } catch (IgniteCheckedException | IgniteException ex) { GridNearTxQueryEnlistResponse res = new GridNearTxQueryEnlistResponse(req.cacheId(), @@ -1918,8 +1914,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach req.topologyVersion(), req.threadId(), req.txTimeout(), - req.taskNameHash(), - req.mvccSnapshot()); + req.taskNameHash()); } catch (Throwable e) { GridNearTxQueryResultsEnlistResponse res = new GridNearTxQueryResultsEnlistResponse(req.cacheId(), @@ -1981,8 +1976,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach req.topologyVersion(), req.threadId(), req.txTimeout(), - req.taskNameHash(), - req.mvccSnapshot()); + req.taskNameHash()); } catch (IgniteCheckedException | IgniteException ex) { GridNearTxEnlistResponse res = new GridNearTxEnlistResponse(req.cacheId(), @@ -2035,7 +2029,6 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach * @param nearThreadId Near node thread id. * @param timeout Timeout. * @param txTaskNameHash Transaction task name hash. - * @param snapshot Mvcc snapsht. * @return Transaction. */ public GridDhtTxLocal initTxTopologyVersion(UUID nodeId, @@ -2047,8 +2040,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach AffinityTopologyVersion topVer, long nearThreadId, long timeout, - int txTaskNameHash, - MvccSnapshot snapshot + int txTaskNameHash ) throws IgniteException, IgniteCheckedException { assert ctx.affinityNode(); @@ -2144,7 +2136,6 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach throw new IgniteCheckedException(msg); } - tx.mvccSnapshot(snapshot); tx.topologyVersion(topVer); } finally { @@ -2230,9 +2221,6 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach false, null); - tx.mvccSnapshot(new MvccSnapshotWithoutTxs(req0.coordinatorVersion(), req0.counter(), - MVCC_OP_COUNTER_NA, req0.cleanupVersion())); - tx = ctx.tm().onCreated(null, tx); if (tx == null || !ctx.tm().onStarted(tx)) { @@ -2243,12 +2231,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach assert tx != null; - MvccSnapshot s0 = tx.mvccSnapshot(); - - MvccSnapshot snapshot = new MvccSnapshotWithoutTxs(s0.coordinatorVersion(), s0.counter(), - req.operationCounter(), s0.cleanupVersion()); - - ctx.tm().txHandler().mvccEnlistBatch(tx, ctx, req.op(), req.keys(), req.values(), snapshot, + ctx.tm().txHandler().mvccEnlistBatch(tx, ctx, req.op(), req.keys(), req.values(), null, req.dhtFutureId(), req.batchId()); GridDhtTxQueryEnlistResponse res = new GridDhtTxQueryEnlistResponse(req.cacheId(), diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java index 982e49a1bbc..d0b68939908 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java @@ -35,7 +35,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheCompoundIdentityFutu import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxMapping; import org.apache.ignite.internal.processors.cache.mvcc.MvccFuture; -import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot; import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; import org.apache.ignite.internal.processors.cache.transactions.TxCounters; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; @@ -317,8 +316,6 @@ public final class GridDhtTxFinishFuture<K, V> extends GridCacheCompoundIdentity MTC.supportContinual(span = cctx.kernalContext().tracing().create(TX_DHT_FINISH, MTC.span()))) { boolean sync; - assert tx.mvccSnapshot() == null; - if (!F.isEmpty(dhtMap) || !F.isEmpty(nearMap)) sync = finish(commit, dhtMap, nearMap); else if (!commit && !F.isEmpty(tx.lockTransactionNodes())) @@ -346,7 +343,7 @@ public final class GridDhtTxFinishFuture<K, V> extends GridCacheCompoundIdentity boolean sync = tx.syncMode() == FULL_SYNC; - if (tx.explicitLock() || tx.queryEnlisted()) + if (tx.explicitLock()) sync = true; boolean res = false; @@ -384,7 +381,7 @@ public final class GridDhtTxFinishFuture<K, V> extends GridCacheCompoundIdentity tx.activeCachesDeploymentEnabled(), false, false, - tx.mvccSnapshot(), + null, cctx.tm().txHandler().filterUpdateCountersForBackupNode(tx, n)); try { @@ -435,19 +432,13 @@ public final class GridDhtTxFinishFuture<K, V> extends GridCacheCompoundIdentity boolean sync = tx.syncMode() == FULL_SYNC; - if (tx.explicitLock() || tx.queryEnlisted()) + if (tx.explicitLock()) sync = true; boolean res = false; int miniId = 0; - // Do not need process active transactions on backups. - MvccSnapshot mvccSnapshot = tx.mvccSnapshot(); - - if (mvccSnapshot != null) - mvccSnapshot = mvccSnapshot.withoutActiveTransactions(); - // Create mini futures. for (GridDistributedTxMapping dhtMapping : dhtMap.values()) { ClusterNode n = dhtMapping.primary(); @@ -489,7 +480,7 @@ public final class GridDhtTxFinishFuture<K, V> extends GridCacheCompoundIdentity null, false, false, - mvccSnapshot, + null, commit ? null : cctx.tm().txHandler().filterUpdateCountersForBackupNode(tx, n)); req.writeVersion(tx.writeVersion() != null ? tx.writeVersion() : tx.xidVersion()); @@ -566,7 +557,7 @@ public final class GridDhtTxFinishFuture<K, V> extends GridCacheCompoundIdentity tx.activeCachesDeploymentEnabled(), false, false, - mvccSnapshot, + null, null); req.writeVersion(tx.writeVersion()); 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 2289b371ba6..1de184b9d60 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 @@ -42,7 +42,6 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPr import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter; -import org.apache.ignite.internal.processors.cache.transactions.TxCounters; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.F0; import org.apache.ignite.internal.util.GridLeanMap; @@ -939,13 +938,4 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter { public void incrementLockCounter() { txCounters(true).incrementLockCounter(); } - - /** - * @return Current value of lock counter. - */ - public int lockCounter() { - TxCounters txCntrs = txCounters(false); - - return txCntrs != null ? txCntrs.lockCounter() : 0; - } } 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 6c3f87c2218..9eee87b3845 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 @@ -67,7 +67,6 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.topology.Grid import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareRequest; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareResponse; -import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot; import org.apache.ignite.internal.processors.cache.mvcc.txlog.TxState; import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; @@ -1394,12 +1393,6 @@ public final class GridDhtTxPrepareFuture extends GridCacheCompoundFuture<Ignite final long timeout = timeoutObj != null ? timeoutObj.timeout : 0; - // Do not need process active transactions on backups. - MvccSnapshot mvccSnapshot = tx.mvccSnapshot(); - - if (mvccSnapshot != null) - mvccSnapshot = mvccSnapshot.withoutActiveTransactions(); - // Create mini futures. for (GridDistributedTxMapping dhtMapping : tx.dhtMap().values()) { assert !dhtMapping.empty() || dhtMapping.queryUpdate(); @@ -1439,7 +1432,7 @@ public final class GridDhtTxPrepareFuture extends GridCacheCompoundFuture<Ignite tx.activeCachesDeploymentEnabled(), tx.storeWriteThrough(), retVal, - mvccSnapshot, + null, cctx.tm().txHandler().filterUpdateCountersForBackupNode(tx, n)); req.queryUpdate(dhtMapping.queryUpdate()); @@ -1553,7 +1546,7 @@ public final class GridDhtTxPrepareFuture extends GridCacheCompoundFuture<Ignite tx.activeCachesDeploymentEnabled(), tx.storeWriteThrough(), retVal, - mvccSnapshot, + null, null); for (IgniteTxEntry entry : nearMapping.entries()) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/NearTxQueryEnlistResultHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/NearTxQueryEnlistResultHandler.java index 30efc103ab4..0329b0e31b2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/NearTxQueryEnlistResultHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/NearTxQueryEnlistResultHandler.java @@ -76,10 +76,10 @@ public final class NearTxQueryEnlistResultHandler implements CI1<IgniteInternalF try { future.get(); - assert future.tx.queryEnlisted() || future.cnt == 0; + assert future.cnt == 0; return new GridNearTxQueryEnlistResponse(future.cctx.cacheId(), future.nearFutId, future.nearMiniId, - future.nearLockVer, future.cnt, future.tx.empty() && !future.tx.queryEnlisted(), future.newDhtNodes); + future.nearLockVer, future.cnt, future.tx.empty(), future.newDhtNodes); } catch (IgniteCheckedException e) { return new GridNearTxQueryEnlistResponse(future.cctx.cacheId(), future.nearFutId, future.nearMiniId, future.nearLockVer, e); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxAbstractEnlistFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxAbstractEnlistFuture.java index e2e9bddfe11..e5e534ac565 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxAbstractEnlistFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxAbstractEnlistFuture.java @@ -37,7 +37,6 @@ import org.apache.ignite.internal.processors.cache.distributed.GridDistributedTx import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxAbstractEnlistFuture; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxLocalAdapter; -import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.processors.timeout.GridTimeoutObjectAdapter; import org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException; @@ -69,9 +68,6 @@ public abstract class GridNearTxAbstractEnlistFuture<T> extends GridCacheCompoun /** */ protected AffinityTopologyVersion topVer; - /** MVCC snapshot. */ - protected MvccSnapshot mvccSnapshot; - /** Logger. */ @GridToStringExclude protected final IgniteLogger log; @@ -122,10 +118,6 @@ public abstract class GridNearTxAbstractEnlistFuture<T> extends GridCacheCompoun lockVer = tx.xidVersion(); futId = IgniteUuid.randomUuid(); - mvccSnapshot = tx.mvccSnapshot(); - - assert mvccSnapshot != null; - log = cctx.logger(getClass()); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxEnlistFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxEnlistFuture.java index 697f194e48d..285dced9750 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxEnlistFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxEnlistFuture.java @@ -40,7 +40,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheReturn; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxEnlistFuture; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxRemote; -import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshotWithoutTxs; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.processors.query.EnlistOperation; import org.apache.ignite.internal.processors.query.UpdateSourceIterator; @@ -55,7 +54,6 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.jetbrains.annotations.Nullable; import static org.apache.ignite.internal.processors.cache.distributed.dht.NearTxResultHandler.createResponse; -import static org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.MVCC_OP_COUNTER_NA; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; @@ -389,9 +387,6 @@ public class GridNearTxEnlistFuture extends GridNearTxAbstractEnlistFuture<GridC false, null); - dhtTx.mvccSnapshot(new MvccSnapshotWithoutTxs(mvccSnapshot.coordinatorVersion(), - mvccSnapshot.counter(), MVCC_OP_COUNTER_NA, mvccSnapshot.cleanupVersion())); - dhtTx = cctx.tm().onCreated(null, dhtTx); if (dhtTx == null || !cctx.tm().onStarted(dhtTx)) { @@ -401,7 +396,7 @@ public class GridNearTxEnlistFuture extends GridNearTxAbstractEnlistFuture<GridC } cctx.tm().txHandler().mvccEnlistBatch(dhtTx, cctx, it.operation(), keys, vals, - mvccSnapshot.withoutActiveTransactions(), null, -1); + null, null, -1); } catch (IgniteCheckedException e) { onDone(e); @@ -448,7 +443,7 @@ public class GridNearTxEnlistFuture extends GridNearTxAbstractEnlistFuture<GridC batchId, topVer, lockVer, - mvccSnapshot, + null, clientFirst, remainingTime(), tx.remainingTime(), @@ -484,7 +479,7 @@ public class GridNearTxEnlistFuture extends GridNearTxAbstractEnlistFuture<GridC GridDhtTxEnlistFuture fut = new GridDhtTxEnlistFuture(nodeId, lockVer, - mvccSnapshot, + null, futId, batchId, tx, 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 cd28b6614bb..741428ee34a 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 @@ -764,7 +764,7 @@ public final class GridNearTxFinishFuture<K, V> extends GridCacheCompoundIdentit null, tx.size(), tx.taskNameHash(), - tx.mvccSnapshot(), + null, tx.activeCachesDeploymentEnabled() ); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java index dd84d3fc064..0f37686719c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java @@ -24,7 +24,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; import java.util.UUID; @@ -62,17 +61,11 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheE import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishFuture; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxLocalAdapter; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture; -import org.apache.ignite.internal.processors.cache.distributed.dht.GridInvokeValue; import org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtDetachedCacheEntry; import org.apache.ignite.internal.processors.cache.distributed.near.consistency.GridNearReadRepairCheckOnlyFuture; import org.apache.ignite.internal.processors.cache.distributed.near.consistency.GridNearReadRepairFuture; import org.apache.ignite.internal.processors.cache.distributed.near.consistency.IgniteConsistencyViolationException; import org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo; -import org.apache.ignite.internal.processors.cache.mvcc.MvccCoordinator; -import org.apache.ignite.internal.processors.cache.mvcc.MvccCoordinatorChangeAware; -import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot; -import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshotFuture; -import org.apache.ignite.internal.processors.cache.mvcc.MvccUtils; import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey; @@ -81,8 +74,6 @@ import org.apache.ignite.internal.processors.cache.transactions.TransactionProxy import org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl; import org.apache.ignite.internal.processors.cache.transactions.TransactionProxyRollbackOnlyImpl; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; -import org.apache.ignite.internal.processors.query.EnlistOperation; -import org.apache.ignite.internal.processors.query.UpdateSourceIterator; import org.apache.ignite.internal.processors.timeout.GridTimeoutObject; import org.apache.ignite.internal.processors.tracing.MTC; import org.apache.ignite.internal.transactions.IgniteTxOptimisticCheckedException; @@ -104,7 +95,6 @@ import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiClosure; -import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.lang.IgniteClosure; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.plugin.security.SecurityPermission; @@ -124,7 +114,6 @@ import static org.apache.ignite.internal.processors.cache.transactions.IgniteTxE import static org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings; import static org.apache.ignite.internal.processors.tracing.SpanType.TX_NEAR_ENLIST_READ; import static org.apache.ignite.internal.processors.tracing.SpanType.TX_NEAR_ENLIST_WRITE; -import static org.apache.ignite.transactions.TransactionState.ACTIVE; import static org.apache.ignite.transactions.TransactionState.COMMITTED; import static org.apache.ignite.transactions.TransactionState.COMMITTING; import static org.apache.ignite.transactions.TransactionState.MARKED_ROLLBACK; @@ -138,7 +127,7 @@ import static org.apache.ignite.transactions.TransactionState.UNKNOWN; * Replicated user transaction. */ @SuppressWarnings("unchecked") -public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeoutObject, AutoCloseable, MvccCoordinatorChangeAware { +public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeoutObject, AutoCloseable { /** Prepare future updater. */ private static final AtomicReferenceFieldUpdater<GridNearTxLocal, IgniteInternalFuture> PREP_FUT_UPD = AtomicReferenceFieldUpdater.newUpdater(GridNearTxLocal.class, IgniteInternalFuture.class, "prepFut"); @@ -147,10 +136,6 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou private static final AtomicReferenceFieldUpdater<GridNearTxLocal, NearTxFinishFuture> FINISH_FUT_UPD = AtomicReferenceFieldUpdater.newUpdater(GridNearTxLocal.class, NearTxFinishFuture.class, "finishFut"); - /** */ - private static final String TX_TYPE_MISMATCH_ERR_MSG = - "SQL queries and cache operations may not be used in the same transaction."; - /** DHT mappings. */ private final IgniteTxMappings mappings; @@ -229,18 +214,6 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou /** Tx label. */ @Nullable private final String lb; - /** Whether this is Mvcc transaction or not.<p> - * {@code null} means there haven't been any calls made on this transaction, and first operation will give this - * field actual value. - */ - private Boolean mvccOp; - - /** */ - private long qryId = MVCC_TRACKER_ID_NA; - - /** */ - private long crdVer; - /** * @param ctx Cache registry. * @param implicit Implicit flag. @@ -251,7 +224,6 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou * @param isolation Isolation. * @param timeout Timeout. * @param storeEnabled Store enabled flag. - * @param mvccOp Whether this transaction was started via SQL API or not, or {@code null} if unknown. * @param txSize Transaction size. * @param subjId Subject ID. * @param taskNameHash Task name hash code. @@ -268,7 +240,6 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou TransactionIsolation isolation, long timeout, boolean storeEnabled, - Boolean mvccOp, int txSize, @Nullable UUID subjId, int taskNameHash, @@ -296,8 +267,6 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou mappings = implicitSingle ? new IgniteTxMappingsSingleImpl() : new IgniteTxMappingsImpl(); - this.mvccOp = mvccOp; - this.txDumpsThrottling = txDumpsThrottling; initResult(); @@ -603,7 +572,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou assert key != null; try { - beforePut(cacheCtx, retval, false); + beforePut(cacheCtx, retval); final GridCacheReturn ret = new GridCacheReturn(localResult(), false); @@ -721,116 +690,6 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou } } - /** - * Internal method for put and transform operations in Mvcc mode. - * Note: Only one of {@code map}, {@code transformMap} maps must be non-null. - * - * @param cacheCtx Context. - * @param map Key-value map to store. - * @param invokeMap Invoke map. - * @param invokeArgs Optional arguments for EntryProcessor. - * @param retval Key-transform value map to store. - * @param filter Filter. - * @return Operation future. - */ - private <K, V> IgniteInternalFuture mvccPutAllAsync0( - final GridCacheContext cacheCtx, - @Nullable Map<? extends K, ? extends V> map, - @Nullable Map<? extends K, ? extends EntryProcessor<K, V, Object>> invokeMap, - @Nullable final Object[] invokeArgs, - final boolean retval, - @Nullable final CacheEntryPredicate filter - ) { - try { - MvccUtils.requestSnapshot(this); - - beforePut(cacheCtx, retval, true); - } - catch (IgniteCheckedException e) { - return new GridFinishedFuture(e); - } - - if (log.isDebugEnabled()) - log.debug("Called putAllAsync(...) [tx=" + this + ", map=" + map + ", retval=" + retval + "]"); - - assert map != null || invokeMap != null; - - if (F.isEmpty(map) && F.isEmpty(invokeMap)) { - if (implicit()) - try { - commit(); - } - catch (IgniteCheckedException e) { - return new GridFinishedFuture<>(e); - } - - return new GridFinishedFuture<>(new GridCacheReturn(true, false)); - } - - // Set transform flag for operation. - boolean transform = invokeMap != null; - - try { - Set<?> keys = map != null ? map.keySet() : invokeMap.keySet(); - - final Map<KeyCacheObject, Object> enlisted = new LinkedHashMap<>(keys.size()); - - for (Object key : keys) { - if (isRollbackOnly()) - return new GridFinishedFuture<>(timedOut() ? timeoutException() : rollbackException()); - - if (key == null) { - rollback(); - - throw new NullPointerException("Null key."); - } - - Object val = map == null ? null : map.get(key); - EntryProcessor entryProc = transform ? invokeMap.get(key) : null; - - if (val == null && entryProc == null) { - setRollbackOnly(); - - throw new NullPointerException("Null value."); - } - - KeyCacheObject cacheKey = cacheCtx.toCacheKeyObject(key); - - if (transform) - enlisted.put(cacheKey, new GridInvokeValue(entryProc, invokeArgs)); - else - enlisted.put(cacheKey, val); - } - - return updateAsync(cacheCtx, new UpdateSourceIterator<IgniteBiTuple<KeyCacheObject, Object>>() { - - private final Iterator<Map.Entry<KeyCacheObject, Object>> it = enlisted.entrySet().iterator(); - - @Override public EnlistOperation operation() { - return transform ? EnlistOperation.TRANSFORM : EnlistOperation.UPSERT; - } - - @Override public boolean hasNextX() { - return it.hasNext(); - } - - @Override public IgniteBiTuple<KeyCacheObject, Object> nextX() { - Map.Entry<KeyCacheObject, Object> next = it.next(); - - return new IgniteBiTuple<>(next.getKey(), next.getValue()); - } - }, retval, filter, remainingTime()); - } - catch (IgniteCheckedException e) { - return new GridFinishedFuture(e); - } - catch (RuntimeException e) { - onException(); - - throw e; - } - } - /** * Internal method for all put and transform operations. Only one of {@code map}, {@code transformMap} * maps must be non-null. @@ -854,7 +713,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou final boolean retval ) { try { - beforePut(cacheCtx, retval, false); + beforePut(cacheCtx, retval); } catch (IgniteCheckedException e) { return new GridFinishedFuture(e); @@ -1918,179 +1777,6 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou } } - /** - * @param cacheCtx Cache context. - * @param cacheIds Involved cache ids. - * @param parts Partitions. - * @param schema Schema name. - * @param qry Query string. - * @param params Query parameters. - * @param flags Flags. - * @param pageSize Fetch page size. - * @param timeout Timeout. - * @return Operation future. - */ - public IgniteInternalFuture<Long> updateAsync(GridCacheContext cacheCtx, - int[] cacheIds, int[] parts, String schema, String qry, Object[] params, - int flags, int pageSize, long timeout) { - try { - beforePut(cacheCtx, false, true); - - return updateAsync(new GridNearTxQueryEnlistFuture( - cacheCtx, - this, - cacheIds, - parts, - schema, - qry, - params, - flags, - pageSize, - timeout)); - } - catch (IgniteCheckedException e) { - return new GridFinishedFuture(e); - } - catch (RuntimeException e) { - onException(); - - throw e; - } - } - - /** - * @param cacheCtx Cache context. - * @param it Entries iterator. - * @param pageSize Page size. - * @param timeout Timeout. - * @param sequential Sequential locking flag. - * @return Operation future. - */ - public IgniteInternalFuture<Long> updateAsync(GridCacheContext cacheCtx, - UpdateSourceIterator<?> it, int pageSize, long timeout, boolean sequential) { - try { - beforePut(cacheCtx, false, true); - - return updateAsync(new GridNearTxQueryResultsEnlistFuture(cacheCtx, this, - timeout, it, pageSize, sequential)); - } - catch (IgniteCheckedException e) { - return new GridFinishedFuture(e); - } - catch (RuntimeException e) { - onException(); - - throw e; - } - } - - /** - * Executes key-value update operation in Mvcc mode. - * - * @param cacheCtx Cache context. - * @param it Entries iterator. - * @param retval Return value flag. - * @param filter Filter. - * @param timeout Timeout. - * @return Operation future. - */ - private IgniteInternalFuture<GridCacheReturn> updateAsync(GridCacheContext cacheCtx, - UpdateSourceIterator<?> it, - boolean retval, - @Nullable CacheEntryPredicate filter, - long timeout) { - try { - final CacheOperationContext opCtx = cacheCtx.operationContextPerCall(); - - final boolean keepBinary = opCtx != null && opCtx.isKeepBinary(); - - /* TODO: IGNITE-9688: 'sequential' is always true here which can slowdown bulk operations, - but possibly we can safely optimize this. */ - - GridNearTxEnlistFuture fut = new GridNearTxEnlistFuture(cacheCtx, this, - timeout, it, 0, true, filter, retval, keepBinary); - - fut.init(); - - return nonInterruptable(new GridEmbeddedFuture<>(fut.chain(new CX1<IgniteInternalFuture<GridCacheReturn>, Boolean>() { - @Override public Boolean applyx(IgniteInternalFuture<GridCacheReturn> fut0) throws IgniteCheckedException { - fut0.get(); - - return true; - } - }), new PLC1<GridCacheReturn>(null) { - @Override protected GridCacheReturn postLock(GridCacheReturn ret) throws IgniteCheckedException { - GridCacheReturn futRes = fut.get(); - - assert futRes != null; - - mvccSnapshot.incrementOperationCounter(); - - Object val = futRes.value(); - - if (futRes.invokeResult() && val != null) { - assert val instanceof Map; - - val = cacheCtx.unwrapInvokeResult((Map)val, keepBinary); - } - - return new GridCacheReturn( - cacheCtx, - true, - keepBinary, - U.deploymentClassLoader(cctx.kernalContext(), deploymentLdrId), - val, - futRes.success() - ); - } - })); - } - catch (RuntimeException e) { - onException(); - - throw e; - } - } - - /** - * Executes update query operation in Mvcc mode. - * - * @param fut Enlist future. - * @return Operation future. - */ - private IgniteInternalFuture<Long> updateAsync(GridNearTxQueryAbstractEnlistFuture fut) { - try { - fut.init(); - - return nonInterruptable(new GridEmbeddedFuture<>(fut.chain(new CX1<IgniteInternalFuture<Long>, Boolean>() { - @Override public Boolean applyx(IgniteInternalFuture<Long> fut0) throws IgniteCheckedException { - return fut0.get() != null; - } - }), new PLC1<Long>(null) { - @Override protected Long postLock(Long val) throws IgniteCheckedException { - Long res = fut.get(); - - assert mvccSnapshot != null; - assert res != null; - - if (res > 0) { - if (mvccSnapshot.operationCounter() == MvccUtils.MVCC_READ_OP_CNTR) { - throw new IgniteCheckedException("The maximum limit of the number of statements allowed in" + - " one transaction is reached. [max=" + mvccSnapshot.operationCounter() + ']'); - } - - mvccSnapshot.incrementOperationCounter(); - } - - return res; - } - })); - } - finally { - cctx.tm().resetContext(); - } - } - /** * @param cacheCtx Cache context. * @param keys Keys to get. @@ -2886,13 +2572,6 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou c); } - /** - * @return Finished future with error message about tx type mismatch. - */ - private static IgniteInternalFuture txTypeMismatchFinishFuture() { - return new GridFinishedFuture(new IgniteCheckedException(TX_TYPE_MISMATCH_ERR_MSG)); - } - /** * @param cacheCtx Cache context. * @param loadFut Missing keys load future. @@ -3230,77 +2909,6 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou } } - /** {@inheritDoc} */ - @Override public boolean queryEnlisted() { - return false; - } - - /** - * Requests version on coordinator. - * - * @return Future to wait for result. - */ - public IgniteInternalFuture<MvccSnapshot> requestSnapshot() { - if (isRollbackOnly()) - return new GridFinishedFuture<>(rollbackException()); - - MvccSnapshot mvccSnapshot0 = mvccSnapshot; - - if (mvccSnapshot0 != null) - return new GridFinishedFuture<>(mvccSnapshot0); - - GridFutureAdapter<MvccSnapshot> fut = new GridFutureAdapter<>(); - - onResponse0(mvccSnapshot0, fut); - - return fut; - } - - /** */ - private synchronized void onResponse0(MvccSnapshot res, GridFutureAdapter<MvccSnapshot> fut) { - assert mvccSnapshot == null; - - if (state() != ACTIVE) { - // The transaction were concurrently rolled back. - // We need to notify the coordinator about that. - assert isRollbackOnly(); - - fut.onDone(timedOut() ? timeoutException() : rollbackException()); - } - else if (crdVer != res.coordinatorVersion()) { - setRollbackOnly(); - - fut.onDone(new IgniteTxRollbackCheckedException( - "Mvcc coordinator has been changed during request. " + - "Please retry on a stable topology.")); - } - else - fut.onDone(mvccSnapshot = res); - } - - /** {@inheritDoc} */ - @Override public synchronized long onMvccCoordinatorChange(MvccCoordinator newCrd) { - if (isDone // Already finished. - || crdVer == 0 // Mvcc snapshot has not been requested yet or it's an non-mvcc transaction. - || newCrd.version() == crdVer) // Acceptable operations reordering. - return MVCC_TRACKER_ID_NA; - - crdVer = newCrd.version(); - - if (mvccSnapshot == null) - return MVCC_TRACKER_ID_NA; - - if (qryId == MVCC_TRACKER_ID_NA) - qryId = ID_CNTR.incrementAndGet(); - - return qryId; - } - - /** {@inheritDoc} */ - @Override public void mvccSnapshot(MvccSnapshot mvccSnapshot) { - throw new UnsupportedOperationException(); - } - /** * Adds key mapping to dht mapping. * @@ -3960,10 +3568,8 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou * @return Transaction commit future. */ private NearTxFinishFuture finishFuture(boolean fast, boolean commit) { - NearTxFinishFuture fut = fast ? new GridNearTxFastFinishFuture(this, commit) : + return fast ? new GridNearTxFastFinishFuture(this, commit) : new GridNearTxFinishFuture<>(cctx, this, commit); - - return mvccSnapshot != null ? new GridNearTxFinishAndAckFuture(fut) : fut; } /** {@inheritDoc} */ @@ -4046,8 +3652,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou * @return {@code True} if 'fast finish' path can be used for transaction completion. */ private boolean fastFinish() { - return !queryEnlisted() && writeMap().isEmpty() - && ((optimistic() && !serializable()) || readMap().isEmpty()); + return writeMap().isEmpty() && ((optimistic() && !serializable()) || readMap().isEmpty()); } /** @@ -4465,20 +4070,6 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou return hasRemoteLocks; } - /** - * @return {@code true} if this transaction does not have type flag set or it matches invoking operation, - * {@code false} otherwise. - */ - public boolean isOperationAllowed(boolean mvccOp) { - if (this.mvccOp == null) { - this.mvccOp = mvccOp; - - return true; - } - - return this.mvccOp == mvccOp; - } - /** * @return Public API proxy. */ @@ -4676,12 +4267,9 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou /** * @param cacheCtx Cache context. * @param retval Return value flag. - * @param mvccOp SQL operation flag. * @throws IgniteCheckedException If failed. */ - private void beforePut(GridCacheContext cacheCtx, boolean retval, boolean mvccOp) throws IgniteCheckedException { - assert !mvccOp; - + private void beforePut(GridCacheContext cacheCtx, boolean retval) throws IgniteCheckedException { checkUpdatesAllowed(cacheCtx); cacheCtx.checkSecurity(SecurityPermission.CACHE_PUT); @@ -4843,21 +4431,6 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou abstract T finish(T t); } - /** */ - private class MvccTxSnapshotFuture extends MvccSnapshotFuture { - /** {@inheritDoc} */ - @Override public void onResponse(MvccSnapshot res) { - onResponse0(res, this); - } - - /** {@inheritDoc} */ - @Override public void onError(IgniteCheckedException err) { - setRollbackOnly(); - - super.onError(err); - } - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridNearTxLocal.class, this, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryEnlistFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryEnlistFuture.java index 8680065cdcb..0bcd8649086 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryEnlistFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryEnlistFuture.java @@ -150,7 +150,7 @@ public class GridNearTxQueryEnlistFuture extends GridNearTxQueryAbstractEnlistFu locFut = new GridDhtTxQueryEnlistFuture( cctx.localNode().id(), lockVer, - mvccSnapshot, + null, futId, -(++idx), // The common tx logic expects non-zero mini-future ids (negative local and positive non-local). tx, @@ -198,7 +198,7 @@ public class GridNearTxQueryEnlistFuture extends GridNearTxQueryAbstractEnlistFu ++idx, // The common tx logic expects non-zero mini-future ids (negative local and positive non-local). topVer, lockVer, - mvccSnapshot, + null, cacheIds, parts == null ? null : parts.array(), schema, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryResultsEnlistFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryResultsEnlistFuture.java index db9c60873fe..a1ad39b5655 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryResultsEnlistFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryResultsEnlistFuture.java @@ -38,7 +38,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheMessage; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxQueryResultsEnlistFuture; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxRemote; -import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshotWithoutTxs; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.processors.query.EnlistOperation; import org.apache.ignite.internal.processors.query.UpdateSourceIterator; @@ -53,7 +52,6 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.jetbrains.annotations.Nullable; import static org.apache.ignite.internal.processors.cache.distributed.dht.NearTxQueryEnlistResultHandler.createResponse; -import static org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.MVCC_OP_COUNTER_NA; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; @@ -355,9 +353,6 @@ public class GridNearTxQueryResultsEnlistFuture extends GridNearTxQueryAbstractE false, tx.label()); - dhtTx.mvccSnapshot(new MvccSnapshotWithoutTxs(mvccSnapshot.coordinatorVersion(), - mvccSnapshot.counter(), MVCC_OP_COUNTER_NA, mvccSnapshot.cleanupVersion())); - dhtTx = cctx.tm().onCreated(null, dhtTx); if (dhtTx == null || !cctx.tm().onStarted(dhtTx)) { @@ -367,7 +362,7 @@ public class GridNearTxQueryResultsEnlistFuture extends GridNearTxQueryAbstractE } cctx.tm().txHandler().mvccEnlistBatch(dhtTx, cctx, it.operation(), keys, vals, - mvccSnapshot.withoutActiveTransactions(), null, -1); + null, null, -1); } catch (IgniteCheckedException e) { onDone(e); @@ -414,7 +409,7 @@ public class GridNearTxQueryResultsEnlistFuture extends GridNearTxQueryAbstractE batchId, topVer, lockVer, - mvccSnapshot, + null, clientFirst, remainingTime(), tx.remainingTime(), @@ -447,7 +442,7 @@ public class GridNearTxQueryResultsEnlistFuture extends GridNearTxQueryAbstractE GridDhtTxQueryResultsEnlistFuture fut = new GridDhtTxQueryResultsEnlistFuture(nodeId, lockVer, - mvccSnapshot, + null, futId, batchId, tx, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/consistency/GridNearReadRepairAbstractFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/consistency/GridNearReadRepairAbstractFuture.java index ab433894e82..76e6e1db45d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/consistency/GridNearReadRepairAbstractFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/consistency/GridNearReadRepairAbstractFuture.java @@ -201,7 +201,7 @@ public abstract class GridNearReadRepairAbstractFuture extends GridFutureAdapter true, true, tx != null ? tx.label() : null, - tx != null ? tx.mvccSnapshot() : null, + null, node); futs.put(mapping.getKey(), fut); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccUtils.java index f190cc96915..387e97edbec 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccUtils.java @@ -31,7 +31,6 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.transactions.IgniteTxAlreadyCompletedCheckedException; import org.apache.ignite.internal.transactions.IgniteTxUnexpectedStateCheckedException; import org.apache.ignite.internal.util.typedef.internal.CU; -import org.apache.ignite.transactions.TransactionMixedModeException; import org.apache.ignite.transactions.TransactionState; import org.apache.ignite.transactions.TransactionUnsupportedConcurrencyException; import org.jetbrains.annotations.NotNull; @@ -616,7 +615,6 @@ public class MvccUtils { * @param ctx Grid kernal context. * @return Currently started user transaction, or {@code null} if none started. * @throws TransactionUnsupportedConcurrencyException If transaction mode is not supported when MVCC is enabled. - * @throws TransactionMixedModeException If started transaction spans non MVCC caches. */ @Nullable public static GridNearTxLocal tx(GridKernalContext ctx) { return tx(ctx, null); @@ -627,7 +625,6 @@ public class MvccUtils { * @param txId Transaction ID. * @return Currently started user transaction, or {@code null} if none started. * @throws TransactionUnsupportedConcurrencyException If transaction mode is not supported when MVCC is enabled. - * @throws TransactionMixedModeException If started transaction spans non MVCC caches. */ @Nullable public static GridNearTxLocal tx(GridKernalContext ctx, @Nullable GridCacheVersion txId) { IgniteTxManager tm = ctx.cache().context().tm(); @@ -642,14 +639,6 @@ public class MvccUtils { throw new TransactionUnsupportedConcurrencyException("Only pessimistic transactions are supported when MVCC is enabled."); } - - if (!tx.isOperationAllowed(true)) { - tx.setRollbackOnly(); - - throw new TransactionMixedModeException( - "Operations on MVCC caches are not permitted in transactions spanning non MVCC caches." - ); - } } return tx; @@ -695,7 +684,6 @@ public class MvccUtils { REPEATABLE_READ, timeout, cctx == null || !cctx.skipStore(), - true, 0, null ); @@ -719,7 +707,7 @@ public class MvccUtils { if (tx == null) tracker = new MvccQueryTrackerImpl(cctx); else - tracker = new StaticMvccQueryTracker(cctx, requestSnapshot(tx)); + tracker = new StaticMvccQueryTracker(cctx, null); if (tracker.snapshot() == null) // TODO IGNITE-7388 @@ -728,21 +716,6 @@ public class MvccUtils { return tracker; } - /** - * @param tx Transaction. - * @throws IgniteCheckedException If failed. - * @return Mvcc snapshot. - */ - public static MvccSnapshot requestSnapshot(@NotNull GridNearTxLocal tx) throws IgniteCheckedException { - MvccSnapshot snapshot = tx.mvccSnapshot(); - - if (snapshot == null) - // TODO IGNITE-7388 - return tx.requestSnapshot().get(); - - return snapshot; - } - /** */ private static MvccVersion mvccVersion(long crd, long cntr, int opCntr) { return new MvccVersionImpl(crd, cntr, opCntr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/IgniteQueryErrorCode.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/IgniteQueryErrorCode.java index 00fdf55166d..17141927da7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/IgniteQueryErrorCode.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/IgniteQueryErrorCode.java @@ -132,9 +132,6 @@ public final class IgniteQueryErrorCode { /** MVCC disabled. */ public static final int MVCC_DISABLED = 5002; - /** Transaction type mismatch (SQL/non SQL). */ - public static final int TRANSACTION_TYPE_MISMATCH = 5003; - /** Transaction is already completed. */ public static final int TRANSACTION_COMPLETED = 5004; @@ -201,7 +198,6 @@ public final class IgniteQueryErrorCode { case MVCC_DISABLED: case TRANSACTION_EXISTS: - case TRANSACTION_TYPE_MISMATCH: case TRANSACTION_COMPLETED: return SqlStateCode.TRANSACTION_STATE_EXCEPTION; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java index 403950cfa14..80a4eb7c3f0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java @@ -30,7 +30,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedExceptio import org.apache.ignite.internal.processors.cache.GridCacheFilterFailedException; import org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate; import org.apache.ignite.internal.processors.cache.KeyCacheObject; -import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException; import org.apache.ignite.internal.util.lang.GridTuple; @@ -655,16 +654,6 @@ public interface IgniteInternalTx { */ @Nullable public String label(); - /** - * @param mvccSnapshot Mvcc snapshot. - */ - public void mvccSnapshot(MvccSnapshot mvccSnapshot); - - /** - * @return Mvcc snapshot. - */ - public MvccSnapshot mvccSnapshot(); - /** * @return ID of incremental snapshot after which this transaction commits, {@code null} if snapshot isn't running. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java index a9cff2baf99..f3ad8b85cb4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java @@ -192,7 +192,6 @@ public class IgniteTransactionsImpl<K, V> implements IgniteTransactionsEx { isolation, timeout, true, - null, txSize, lb ); 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 5e1bdcda08e..64aee86418e 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 @@ -61,7 +61,6 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.topology.Grid import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheEntry; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal; -import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot; import org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer; import org.apache.ignite.internal.processors.cache.store.CacheStoreManager; import org.apache.ignite.internal.processors.cache.version.GridCacheLazyPlainVersionedEntry; @@ -261,10 +260,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement /** UUID to consistent id mapper. */ protected final ConsistentIdMapper consistentIdMapper; - /** Mvcc tx update snapshot. */ - @GridToStringInclude - protected volatile MvccSnapshot mvccSnapshot; - /** Incremental snapshot ID. */ private @Nullable UUID incSnpId; @@ -420,18 +415,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement this.parentTx = parentTx; } - /** - * @return Mvcc info. - */ - @Override @Nullable public MvccSnapshot mvccSnapshot() { - return mvccSnapshot; - } - - /** {@inheritDoc} */ - @Override public void mvccSnapshot(MvccSnapshot mvccSnapshot) { - this.mvccSnapshot = mvccSnapshot; - } - /** * @return {@code True} if tx should skip adding itself to completed version map on finish. */ 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 f337f40a0e1..e48331f8265 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 @@ -993,11 +993,8 @@ public class IgniteTxHandler { else tx = ctx.tm().tx(dhtVer); - if (tx != null) { - tx.mvccSnapshot(req.mvccSnapshot()); - + if (tx != null) req.txState(tx.txState()); - } if (tx == null && locTx != null && !req.commit()) { U.warn(log, "DHT local tx not found for near local tx rollback " + @@ -1431,7 +1428,6 @@ public class IgniteTxHandler { tx.invalidate(true); if (req.isSystemInvalidate()) tx.systemInvalidate(true); - tx.mvccSnapshot(req.mvccSnapshot()); // Complete remote candidates. tx.doneRemote(req.baseVersion(), null, null, null); @@ -1443,7 +1439,6 @@ public class IgniteTxHandler { tx.txCounters(true).updateCounters(req.updateCounters()); tx.doneRemote(req.baseVersion(), null, null, null); - tx.mvccSnapshot(req.mvccSnapshot()); tx.rollbackRemoteTx(); } } @@ -1481,7 +1476,6 @@ public class IgniteTxHandler { try { tx.commitVersion(req.writeVersion()); tx.invalidate(req.isInvalidate()); - tx.mvccSnapshot(req.mvccSnapshot()); // Complete remote candidates. tx.doneRemote(req.version(), null, null, null); 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 5f9ef732c31..1547cb25faa 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 @@ -144,9 +144,6 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig /** */ private CacheWriteSynchronizationMode syncMode; - /** */ - protected volatile boolean qryEnlisted; - /** * @param cctx Cache registry. * @param xidVer Transaction ID. @@ -538,7 +535,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig Collection<IgniteTxEntry> commitEntries = near() ? allEntries() : writeEntries(); - boolean empty = F.isEmpty(commitEntries) && !queryEnlisted(); + boolean empty = F.isEmpty(commitEntries); // Register this transaction as completed prior to write-phase to // ensure proper lock ordering for removed entries. @@ -1600,13 +1597,6 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig return 0; } - /** - * @return {@code True} if there are entries, enlisted by query. - */ - public boolean queryEnlisted() { - return qryEnlisted; - } - /** * Post-lock closure alias. * 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 47eb1044b8b..cfd09aac31c 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 @@ -701,7 +701,6 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter { TransactionIsolation isolation, long timeout, boolean storeEnabled, - Boolean mvccOp, int txSize, @Nullable String lb ) { @@ -719,7 +718,6 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter { isolation, timeout, storeEnabled, - mvccOp, txSize, securitySubjectId(cctx), taskNameHash, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerUtils.java index 4d1cf81f5fa..b8550e1dc04 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerUtils.java @@ -33,7 +33,6 @@ import org.apache.ignite.internal.processors.query.IgniteSQLException; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.transactions.TransactionAlreadyCompletedException; import org.apache.ignite.transactions.TransactionDuplicateKeyException; -import org.apache.ignite.transactions.TransactionMixedModeException; import org.apache.ignite.transactions.TransactionSerializationException; import org.apache.ignite.transactions.TransactionUnsupportedConcurrencyException; import org.jetbrains.annotations.Nullable; @@ -305,8 +304,6 @@ public abstract class SqlListenerUtils { return IgniteQueryErrorCode.TRANSACTION_COMPLETED; if (e instanceof TransactionDuplicateKeyException) return IgniteQueryErrorCode.DUPLICATE_KEY; - if (e instanceof TransactionMixedModeException) - return IgniteQueryErrorCode.TRANSACTION_TYPE_MISMATCH; if (e instanceof TransactionUnsupportedConcurrencyException) return IgniteQueryErrorCode.UNSUPPORTED_OPERATION; if (e instanceof IgniteSQLException) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/tx/ClientTxStartRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/tx/ClientTxStartRequest.java index ef93627f589..be6021580fd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/tx/ClientTxStartRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/tx/ClientTxStartRequest.java @@ -73,7 +73,6 @@ public class ClientTxStartRequest extends ClientRequest { isolation, timeout, true, - null, 0, lb ); diff --git a/modules/core/src/main/java/org/apache/ignite/transactions/TransactionMixedModeException.java b/modules/core/src/main/java/org/apache/ignite/transactions/TransactionMixedModeException.java deleted file mode 100644 index 187aa2b49e5..00000000000 --- a/modules/core/src/main/java/org/apache/ignite/transactions/TransactionMixedModeException.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.transactions; - -/** - * Exception thrown whenever transaction spans over MVCC and non-MVCC caches. - */ -public class TransactionMixedModeException extends TransactionException { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Creates new exception with given error message. - * - * @param msg Error message. - */ - public TransactionMixedModeException(String msg) { - super(msg); - } -} diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties index 98f58f676b2..f3cce1df51e 100644 --- a/modules/core/src/main/resources/META-INF/classnames.properties +++ b/modules/core/src/main/resources/META-INF/classnames.properties @@ -2461,7 +2461,6 @@ org.apache.ignite.transactions.TransactionDuplicateKeyException org.apache.ignite.transactions.TransactionException org.apache.ignite.transactions.TransactionHeuristicException org.apache.ignite.transactions.TransactionIsolation -org.apache.ignite.transactions.TransactionMixedModeException org.apache.ignite.transactions.TransactionOptimisticException org.apache.ignite.transactions.TransactionRollbackException org.apache.ignite.transactions.TransactionSerializationException diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDataConsistencyOnCommitFailureTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDataConsistencyOnCommitFailureTest.java index 804b9d34f4b..6699d96f218 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDataConsistencyOnCommitFailureTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDataConsistencyOnCommitFailureTest.java @@ -176,7 +176,7 @@ public class TxDataConsistencyOnCommitFailureTest extends GridCommonAbstractTest IgniteTxManager mockTm = Mockito.spy(tm); MockGridNearTxLocal locTx = new MockGridNearTxLocal(ctx, false, false, false, GridIoPolicy.SYSTEM_POOL, - TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ, 0, true, null, 1, null, 0, null, + TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ, 0, true, 1, null, 0, null, null); Mockito.doAnswer(new Answer<GridNearTxLocal>() { @@ -187,7 +187,7 @@ public class TxDataConsistencyOnCommitFailureTest extends GridCommonAbstractTest } }).when(mockTm). newTx(locTx.implicit(), locTx.implicitSingle(), null, locTx.concurrency(), - locTx.isolation(), locTx.timeout(), locTx.storeEnabled(), null, locTx.size(), locTx.label()); + locTx.isolation(), locTx.timeout(), locTx.storeEnabled(), locTx.size(), locTx.label()); ctx.setTxManager(mockTm); } @@ -212,7 +212,6 @@ public class TxDataConsistencyOnCommitFailureTest extends GridCommonAbstractTest * @param isolation Isolation. * @param timeout Timeout. * @param storeEnabled Store enabled. - * @param mvccOp Mvcc op. * @param txSize Tx size. * @param subjId Subj id. * @param taskNameHash Task name hash. @@ -221,9 +220,9 @@ public class TxDataConsistencyOnCommitFailureTest extends GridCommonAbstractTest */ public MockGridNearTxLocal(GridCacheSharedContext ctx, boolean implicit, boolean implicitSingle, boolean sys, byte plc, TransactionConcurrency concurrency, TransactionIsolation isolation, long timeout, - boolean storeEnabled, Boolean mvccOp, int txSize, @Nullable UUID subjId, int taskNameHash, @Nullable String lb, + boolean storeEnabled, int txSize, @Nullable UUID subjId, int taskNameHash, @Nullable String lb, IgniteTxManager.TxDumpsThrottling txDumpsThrottling) { - super(ctx, implicit, implicitSingle, sys, plc, concurrency, isolation, timeout, storeEnabled, mvccOp, + super(ctx, implicit, implicitSingle, sys, plc, concurrency, isolation, timeout, storeEnabled, txSize, subjId, taskNameHash, lb, txDumpsThrottling); } diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java index 03da082f7bd..ec627587d9f 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java @@ -38,7 +38,6 @@ import org.apache.ignite.IgniteDataStreamer; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.IgniteSystemProperties; -import org.apache.ignite.cache.CacheServerNotFoundException; import org.apache.ignite.cache.query.FieldsQueryCursor; import org.apache.ignite.cache.query.QueryCancelledException; import org.apache.ignite.cache.query.SqlFieldsQuery; @@ -52,7 +51,6 @@ import org.apache.ignite.internal.GridTopic; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.binary.BinaryUtils; -import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException; import org.apache.ignite.internal.managers.communication.GridMessageListener; import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; @@ -67,7 +65,6 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.Gri import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal; import org.apache.ignite.internal.processors.cache.mvcc.MvccQueryTracker; import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot; -import org.apache.ignite.internal.processors.cache.mvcc.MvccUtils; import org.apache.ignite.internal.processors.cache.mvcc.StaticMvccQueryTracker; import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow; import org.apache.ignite.internal.processors.cache.query.GridCacheQueryMarshallable; @@ -75,9 +72,7 @@ import org.apache.ignite.internal.processors.cache.query.GridCacheQueryType; import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxAdapter; import org.apache.ignite.internal.processors.cache.tree.CacheDataTree; -import org.apache.ignite.internal.processors.odbc.SqlStateCode; import org.apache.ignite.internal.processors.odbc.jdbc.JdbcParameterMeta; -import org.apache.ignite.internal.processors.query.EnlistOperation; import org.apache.ignite.internal.processors.query.GridQueryCacheObjectsIterator; import org.apache.ignite.internal.processors.query.GridQueryCancel; import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata; @@ -95,8 +90,6 @@ import org.apache.ignite.internal.processors.query.UpdateSourceIterator; import org.apache.ignite.internal.processors.query.h2.affinity.H2PartitionResolver; import org.apache.ignite.internal.processors.query.h2.affinity.PartitionExtractor; import org.apache.ignite.internal.processors.query.h2.dml.DmlDistributedPlanInfo; -import org.apache.ignite.internal.processors.query.h2.dml.DmlUpdateResultsIterator; -import org.apache.ignite.internal.processors.query.h2.dml.DmlUpdateSingleEntryIterator; import org.apache.ignite.internal.processors.query.h2.dml.DmlUtils; import org.apache.ignite.internal.processors.query.h2.dml.UpdateMode; import org.apache.ignite.internal.processors.query.h2.dml.UpdatePlan; @@ -128,7 +121,6 @@ import org.apache.ignite.internal.sql.command.SqlRollbackTransactionCommand; import org.apache.ignite.internal.sql.optimizer.affinity.PartitionResult; import org.apache.ignite.internal.util.GridEmptyCloseableIterator; import org.apache.ignite.internal.util.GridSpinBusyLock; -import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.internal.util.lang.GridCloseableIterator; import org.apache.ignite.internal.util.lang.GridPlainRunnable; import org.apache.ignite.internal.util.lang.IgniteInClosure2X; @@ -159,9 +151,7 @@ import static java.lang.Math.max; import static java.lang.Math.min; import static java.util.Collections.singletonList; import static org.apache.ignite.events.EventType.EVT_SQL_QUERY_EXECUTION; -import static org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.requestSnapshot; import static org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.tx; -import static org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.txStart; import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.TEXT; import static org.apache.ignite.internal.processors.query.h2.H2Utils.UPDATE_RESULT_META; import static org.apache.ignite.internal.processors.query.h2.H2Utils.generateFieldsQueryString; @@ -997,112 +987,100 @@ public class IgniteH2Indexing implements GridQueryIndexing { boolean failOnMultipleStmts, GridQueryCancel cancel ) { - try { - List<FieldsQueryCursor<List<?>>> res = new ArrayList<>(1); + List<FieldsQueryCursor<List<?>>> res = new ArrayList<>(1); - SqlFieldsQuery remainingQry = qry; + SqlFieldsQuery remainingQry = qry; - while (remainingQry != null) { - Span qrySpan = ctx.tracing().create(SQL_QRY, MTC.span()) - .addTag(SQL_SCHEMA, () -> schemaName); + while (remainingQry != null) { + Span qrySpan = ctx.tracing().create(SQL_QRY, MTC.span()) + .addTag(SQL_SCHEMA, () -> schemaName); - try (TraceSurroundings ignored = MTC.supportContinual(qrySpan)) { - // Parse. - QueryParserResult parseRes = parser.parse(schemaName, remainingQry, !failOnMultipleStmts); + try (TraceSurroundings ignored = MTC.supportContinual(qrySpan)) { + // Parse. + QueryParserResult parseRes = parser.parse(schemaName, remainingQry, !failOnMultipleStmts); - qrySpan.addTag(SQL_QRY_TEXT, () -> parseRes.queryDescriptor().sql()); + qrySpan.addTag(SQL_QRY_TEXT, () -> parseRes.queryDescriptor().sql()); - remainingQry = parseRes.remainingQuery(); + remainingQry = parseRes.remainingQuery(); - // Get next command. - QueryDescriptor newQryDesc = parseRes.queryDescriptor(); - QueryParameters newQryParams = parseRes.queryParameters(); + // Get next command. + QueryDescriptor newQryDesc = parseRes.queryDescriptor(); + QueryParameters newQryParams = parseRes.queryParameters(); - // Check if there is enough parameters. Batched statements are not checked at this point - // since they pass parameters differently. - if (!newQryDesc.batched()) { - int qryParamsCnt = F.isEmpty(newQryParams.arguments()) ? 0 : newQryParams.arguments().length; + // Check if there is enough parameters. Batched statements are not checked at this point + // since they pass parameters differently. + if (!newQryDesc.batched()) { + int qryParamsCnt = F.isEmpty(newQryParams.arguments()) ? 0 : newQryParams.arguments().length; - if (qryParamsCnt < parseRes.parametersCount()) - throw new IgniteSQLException("Invalid number of query parameters [expected=" + - parseRes.parametersCount() + ", actual=" + qryParamsCnt + ']'); - } + if (qryParamsCnt < parseRes.parametersCount()) + throw new IgniteSQLException("Invalid number of query parameters [expected=" + + parseRes.parametersCount() + ", actual=" + qryParamsCnt + ']'); + } - // Check if cluster state is valid. - checkClusterState(parseRes); + // Check if cluster state is valid. + checkClusterState(parseRes); - // Execute. - if (parseRes.isCommand()) { - QueryParserResultCommand cmd = parseRes.command(); + // Execute. + if (parseRes.isCommand()) { + QueryParserResultCommand cmd = parseRes.command(); - assert cmd != null; + assert cmd != null; - if (cmd.noOp() && remainingQry == null && newQryDesc.sql().isEmpty()) - continue; + if (cmd.noOp() && remainingQry == null && newQryDesc.sql().isEmpty()) + continue; - FieldsQueryCursor<List<?>> cmdRes = executeCommand( - newQryDesc, - newQryParams, - cliCtx, - cmd - ); - - res.add(cmdRes); - } - else if (parseRes.isDml()) { - QueryParserResultDml dml = parseRes.dml(); + FieldsQueryCursor<List<?>> cmdRes = executeCommand( + newQryDesc, + newQryParams, + cliCtx, + cmd + ); - assert dml != null; + res.add(cmdRes); + } + else if (parseRes.isDml()) { + QueryParserResultDml dml = parseRes.dml(); - List<? extends FieldsQueryCursor<List<?>>> dmlRes = executeDml( - newQryDesc, - newQryParams, - dml, - cancel - ); + assert dml != null; - res.addAll(dmlRes); - } - else { - assert parseRes.isSelect(); + List<? extends FieldsQueryCursor<List<?>>> dmlRes = executeDml( + newQryDesc, + newQryParams, + dml, + cancel + ); - QueryParserResultSelect select = parseRes.select(); + res.addAll(dmlRes); + } + else { + assert parseRes.isSelect(); - assert select != null; + QueryParserResultSelect select = parseRes.select(); - List<? extends FieldsQueryCursor<List<?>>> qryRes = executeSelect( - newQryDesc, - newQryParams, - select, - keepBinary, - cancel - ); + assert select != null; - res.addAll(qryRes); - } - } - catch (Throwable th) { - qrySpan.addTag(ERROR, th::getMessage).end(); + List<? extends FieldsQueryCursor<List<?>>> qryRes = executeSelect( + newQryDesc, + newQryParams, + select, + keepBinary, + cancel + ); - throw th; + res.addAll(qryRes); } } + catch (Throwable th) { + qrySpan.addTag(ERROR, th::getMessage).end(); - if (res.isEmpty()) - throw new SqlParseException(qry.getSql(), 0, IgniteQueryErrorCode.PARSING, "Invalid SQL query."); - - return res; + throw th; + } } - catch (RuntimeException | Error e) { - GridNearTxLocal tx = ctx.cache().context().tm().tx(); - if (tx != null && tx.mvccSnapshot() != null && - (!(e instanceof IgniteSQLException) || /* Parsing errors should not rollback Tx. */ - ((IgniteSQLException)e).sqlState() != SqlStateCode.PARSING_EXCEPTION)) - tx.setRollbackOnly(); + if (res.isEmpty()) + throw new SqlParseException(qry.getSql(), 0, IgniteQueryErrorCode.PARSING, "Invalid SQL query."); - throw e; - } + return res; } /** @@ -2511,187 +2489,6 @@ public class IgniteH2Indexing implements GridQueryIndexing { } } - /** - * Execute update in transactional mode. - * - * @param qryId Query id. - * @param qryDesc Query descriptor. - * @param qryParams Query parameters. - * @param dml Plan. - * @param loc Local flag. - * @param cancel Cancel hook. - * @return Update result. - * @throws IgniteCheckedException If failed. - */ - private UpdateResult executeUpdateTransactional( - long qryId, - QueryDescriptor qryDesc, - QueryParameters qryParams, - QueryParserResultDml dml, - boolean loc, - GridQueryCancel cancel - ) throws IgniteCheckedException { - UpdatePlan plan = dml.plan(); - - GridCacheContext cctx = plan.cacheContext(); - - assert cctx != null; - assert cctx.transactional(); - - GridNearTxLocal tx = tx(ctx); - - boolean implicit = (tx == null); - - boolean commit = implicit && qryParams.autoCommit(); - - if (implicit) - tx = txStart(cctx, qryParams.timeout()); - - requestSnapshot(tx); - - try (GridNearTxLocal toCommit = commit ? tx : null) { - DmlDistributedPlanInfo distributedPlan = loc ? null : plan.distributedPlan(); - - long timeout = implicit - ? tx.remainingTime() - : operationTimeout(qryParams.timeout(), tx); - - if (cctx.isReplicated() || distributedPlan == null || ((plan.mode() == UpdateMode.INSERT - || plan.mode() == UpdateMode.MERGE) && !plan.isLocalSubquery())) { - - boolean sequential = true; - - UpdateSourceIterator<?> it; - - if (plan.fastResult()) { - IgniteBiTuple row = plan.getFastRow(qryParams.arguments()); - - assert row != null; - - EnlistOperation op = UpdatePlan.enlistOperation(plan.mode()); - - it = new DmlUpdateSingleEntryIterator<>(op, op.isDeleteOrLock() ? row.getKey() : row); - } - else if (plan.hasRows()) { - it = new DmlUpdateResultsIterator( - UpdatePlan.enlistOperation(plan.mode()), - plan, - plan.createRows(qryParams.arguments()) - ); - } - else { - SqlFieldsQuery selectFieldsQry = new SqlFieldsQuery(plan.selectQuery(), qryDesc.collocated()) - .setArgs(qryParams.arguments()) - .setDistributedJoins(qryDesc.distributedJoins()) - .setEnforceJoinOrder(qryDesc.enforceJoinOrder()) - .setLocal(qryDesc.local()) - .setPageSize(qryParams.pageSize()) - .setTimeout((int)timeout, TimeUnit.MILLISECONDS) - // In MVCC mode we can use lazy mode always (when is set up) without dependency on - // updated columns and WHERE condition. - .setLazy(qryParams.lazy()); - - FieldsQueryCursor<List<?>> cur = executeSelectForDml( - qryId, - qryDesc.schemaName(), - selectFieldsQry, - MvccUtils.mvccTracker(cctx, tx), - cancel, - (int)timeout - ); - - it = plan.iteratorForTransaction(connMgr, cur); - } - - //TODO: IGNITE-11176 - Need to support cancellation - IgniteInternalFuture<Long> fut = tx.updateAsync( - cctx, - it, - qryParams.pageSize(), - timeout, - sequential - ); - - UpdateResult res = new UpdateResult(fut.get(), X.EMPTY_OBJECT_ARRAY, - plan.distributedPlan() != null ? plan.distributedPlan().derivedPartitions() : null); - - if (commit) - toCommit.commit(); - - return res; - } - - int[] ids = U.toIntArray(distributedPlan.getCacheIds()); - - int flags = 0; - - if (qryDesc.enforceJoinOrder()) - flags |= GridH2QueryRequest.FLAG_ENFORCE_JOIN_ORDER; - - if (distributedPlan.isReplicatedOnly()) - flags |= GridH2QueryRequest.FLAG_REPLICATED; - - if (qryParams.lazy()) - flags |= GridH2QueryRequest.FLAG_LAZY; - - flags = GridH2QueryRequest.setDataPageScanEnabled(flags, - qryParams.dataPageScanEnabled()); - - int[] parts = PartitionResult.calculatePartitions( - qryParams.partitions(), - distributedPlan.derivedPartitions(), - qryParams.arguments() - ); - - if (parts != null && parts.length == 0) - return new UpdateResult(0, X.EMPTY_OBJECT_ARRAY, distributedPlan.derivedPartitions()); - else { - //TODO: IGNITE-11176 - Need to support cancellation - IgniteInternalFuture<Long> fut = tx.updateAsync( - cctx, - ids, - parts, - qryDesc.schemaName(), - qryDesc.sql(), - qryParams.arguments(), - flags, - qryParams.pageSize(), - timeout - ); - - UpdateResult res = new UpdateResult(fut.get(), X.EMPTY_OBJECT_ARRAY, - distributedPlan.derivedPartitions()); - - if (commit) - toCommit.commit(); - - return res; - } - } - catch (ClusterTopologyServerNotFoundException e) { - throw new CacheServerNotFoundException(e.getMessage(), e); - } - catch (IgniteCheckedException e) { - IgniteSQLException sqlEx = X.cause(e, IgniteSQLException.class); - - if (sqlEx != null) - throw sqlEx; - - Exception ex = IgniteUtils.convertExceptionNoWrap(e); - - if (ex instanceof IgniteException) - throw (IgniteException)ex; - - U.error(log, "Error during update [localNodeId=" + ctx.localNodeId() + "]", ex); - - throw new IgniteSQLException("Failed to run update. " + ex.getMessage(), ex); - } - finally { - if (commit) - cctx.tm().resetContext(); - } - } - /** * @return Heavy queries tracker. */ diff --git a/modules/jta/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManager.java b/modules/jta/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManager.java index 88c86b2040a..8dcdd574fa6 100644 --- a/modules/jta/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManager.java +++ b/modules/jta/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManager.java @@ -167,7 +167,6 @@ public class CacheJtaManager extends CacheJtaManagerAdapter { tCfg.getDefaultTxIsolation(), tCfg.getDefaultTxTimeout(), /*store enabled*/true, - /*sql*/false, /*tx size*/0, null );