You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by am...@apache.org on 2019/06/05 11:08:33 UTC

[ignite] 30/31: GG-19169: Fix wrong mvcc tx detection. This closes #78.

This is an automated email from the ASF dual-hosted git repository.

amashenkov pushed a commit to branch gg-19225
in repository https://gitbox.apache.org/repos/asf/ignite.git

commit b1a49bef46bba191288b2bb6fbabe7a9f94b0204
Author: Andrey V. Mashenkov <an...@gmail.com>
AuthorDate: Wed Jun 5 13:41:56 2019 +0300

    GG-19169: Fix wrong mvcc tx detection. This closes #78.
---
 .../processors/query/h2/IgniteH2Indexing.java      | 56 ++++++++++------------
 1 file changed, 25 insertions(+), 31 deletions(-)

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 b90093c..233b551 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
@@ -852,10 +852,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
             boolean forUpdate = GridSqlQueryParser.isForUpdateQuery(p);
 
-            if (forUpdate && !mvccEnabled)
-                throw new IgniteSQLException("SELECT FOR UPDATE query requires transactional " +
-                    "cache with MVCC enabled.", IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
-
             if (this.ctx.security().enabled()) {
                 GridSqlQueryParser parser = new GridSqlQueryParser(false);
 
@@ -868,44 +864,42 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
             int opTimeout = qryTimeout;
 
-            if (mvccEnabled) {
-                if (mvccTracker == null)
-                    mvccTracker = mvccTracker(stmt, startTx);
+            if (mvccTracker == null)
+                mvccTracker = mvccTracker(stmt, startTx);
 
-                if (mvccTracker != null) {
-                    ctx.mvccSnapshot(mvccTracker.snapshot());
+            if (mvccEnabled = (mvccTracker != null)) {
+                ctx.mvccSnapshot(mvccTracker.snapshot());
 
-                    tx = checkActive(tx(this.ctx));
+                tx = checkActive(tx(this.ctx));
 
-                    opTimeout = operationTimeout(opTimeout, tx);
-                }
+                opTimeout = operationTimeout(opTimeout, tx);
+            }
 
-                if (forUpdate) {
-                    if (mvccTracker == null)
-                        throw new IgniteSQLException("SELECT FOR UPDATE query requires transactional " +
-                            "cache with MVCC enabled.", IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
+            if (forUpdate) {
+                if (!mvccEnabled)
+                    throw new IgniteSQLException("SELECT FOR UPDATE query requires transactional " +
+                        "cache with MVCC enabled.", IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
 
-                    GridSqlStatement stmt0 = new GridSqlQueryParser(false).parse(p);
+                GridSqlStatement stmt0 = new GridSqlQueryParser(false).parse(p);
 
-                    qry = GridSqlQueryParser.rewriteQueryForUpdateIfNeeded(stmt0, forUpdate = tx != null);
+                qry = GridSqlQueryParser.rewriteQueryForUpdateIfNeeded(stmt0, forUpdate = tx != null);
 
-                    stmt = preparedStatementWithParams(conn, qry, params, true);
+                stmt = preparedStatementWithParams(conn, qry, params, true);
 
-                    if (forUpdate) {
-                        GridCacheContext cctx = mvccTracker.context();
+                if (forUpdate) {
+                    GridCacheContext cctx = mvccTracker.context();
 
-                        try {
-                            if (tx.topologyVersionSnapshot() == null)
-                                new TxTopologyVersionFuture(tx, cctx).get();
-                        }
-                        catch (Exception e) {
-                            throw new IgniteSQLException("Failed to lock topology for SELECT FOR UPDATE query.", e);
-                        }
+                    try {
+                        if (tx.topologyVersionSnapshot() == null)
+                            new TxTopologyVersionFuture(tx, cctx).get();
+                    }
+                    catch (Exception e) {
+                        throw new IgniteSQLException("Failed to lock topology for SELECT FOR UPDATE query.", e);
+                    }
 
-                        sfuFut = new GridNearTxSelectForUpdateFuture(cctx, tx, opTimeout);
+                    sfuFut = new GridNearTxSelectForUpdateFuture(cctx, tx, opTimeout);
 
-                        sfuFut.initLocal();
-                    }
+                    sfuFut.initLocal();
                 }
             }