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

agingade pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new f504c7d  GEODE-4033: Exception is thrown when Tx Id is not found on 
server dur… (#1115)
f504c7d is described below

commit f504c7d607a405fcd156092d050df2edc33e4642
Author: agingade <aging...@pivotal.io>
AuthorDate: Mon Dec 4 11:50:33 2017 -0800

    GEODE-4033: Exception is thrown when Tx Id is not found on server dur… 
(#1115)
    
    * GEODE-4033: Exception is thrown when Tx Id is not found on server during 
failover
---
 .../cache/client/internal/OpExecutorImpl.java      | 19 +----
 .../cache/client/internal/TXFailoverOpTest.java    | 82 ++++++++++++++++++++++
 2 files changed, 85 insertions(+), 16 deletions(-)

diff --git 
a/geode-core/src/main/java/org/apache/geode/cache/client/internal/OpExecutorImpl.java
 
b/geode-core/src/main/java/org/apache/geode/cache/client/internal/OpExecutorImpl.java
index 32ecd13..107d733 100644
--- 
a/geode-core/src/main/java/org/apache/geode/cache/client/internal/OpExecutorImpl.java
+++ 
b/geode-core/src/main/java/org/apache/geode/cache/client/internal/OpExecutorImpl.java
@@ -251,21 +251,8 @@ public class OpExecutorImpl implements ExecutablePool {
     int transactionId = absOp.getMessage().getTransactionId();
     // for CommitOp we do not have transactionId in AbstractOp
     // so set it explicitly for TXFailoverOp
-    try {
-      TXFailoverOp.execute(this.pool, transactionId);
-    } catch (TransactionException e) {
-      // If this is the first operation in the transaction then
-      // do not throw TransactionDataNodeHasDeparted back to the
-      // user, re-try the op instead. fixes bug 44375. NOTE: TXFailoverOp
-      // is sent even after first op, as it is not known if the first
-      // operation has established a TXState already
-      TXStateProxy txState = TXManagerImpl.getCurrentTXState();
-      if (txState == null) {
-        throw e;
-      } else if (txState.operationCount() > 1) {
-        throw e;
-      }
-    }
+    TXFailoverOp.execute(this.pool, transactionId);
+
     if (op instanceof ExecuteRegionFunctionOpImpl) {
       op = new ExecuteRegionFunctionOpImpl((ExecuteRegionFunctionOpImpl) op,
           (byte) 1/* isReExecute */, new HashSet<String>());
@@ -342,7 +329,7 @@ public class OpExecutorImpl implements ExecutablePool {
     return executeOnServer(server, op, accessed, onlyUseExistingCnx);
   }
 
-  private Object executeOnServer(ServerLocation p_server, Op op, boolean 
accessed,
+  protected Object executeOnServer(ServerLocation p_server, Op op, boolean 
accessed,
       boolean onlyUseExistingCnx) {
     ServerLocation server = p_server;
     boolean returnCnx = true;
diff --git 
a/geode-core/src/test/java/org/apache/geode/cache/client/internal/TXFailoverOpTest.java
 
b/geode-core/src/test/java/org/apache/geode/cache/client/internal/TXFailoverOpTest.java
new file mode 100644
index 0000000..d315011
--- /dev/null
+++ 
b/geode-core/src/test/java/org/apache/geode/cache/client/internal/TXFailoverOpTest.java
@@ -0,0 +1,82 @@
+/*
+ * 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.geode.cache.client.internal;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.ExpectedException;
+
+import org.apache.geode.CancelCriterion;
+import org.apache.geode.cache.TransactionException;
+import org.apache.geode.cache.client.ServerConnectivityException;
+import org.apache.geode.cache.client.internal.pooling.ConnectionManager;
+import org.apache.geode.distributed.internal.ServerLocation;
+import org.apache.geode.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class TXFailoverOpTest {
+
+  @Rule
+  public ExpectedException expectedException = ExpectedException.none();
+
+  private ConnectionManager manager;
+  private EndpointManager endpointManager;
+  private QueueManager queueManager;
+  private RegisterInterestTracker riTracker;
+  private CancelCriterion cancelCriterion;
+  private PoolImpl mockPool;
+
+  @Before
+  public void setUp() {
+    endpointManager = mock(EndpointManager.class);
+    queueManager = mock(QueueManager.class);
+    manager = mock(ConnectionManager.class);
+    riTracker = mock(RegisterInterestTracker.class);
+    cancelCriterion = mock(CancelCriterion.class);
+    mockPool = mock(PoolImpl.class);
+    when(mockPool.execute(any())).thenThrow(new 
TransactionException()).thenReturn(true);
+  }
+
+  private OpExecutorImpl getTestableOpExecutorImpl() {
+    return new OpExecutorImpl(manager, queueManager, endpointManager, 
riTracker, 3, 10, false,
+        cancelCriterion, mockPool) {
+
+      public ServerLocation getNextOpServerLocation() {
+        return mock(ServerLocation.class);
+      }
+
+      protected Object executeOnServer(ServerLocation p_server, Op op, boolean 
accessed,
+          boolean onlyUseExistingCnx) {
+        throw new ServerConnectivityException();
+      }
+    };
+  }
+
+  @Test
+  public void txFailoverThrowsTransactionExceptionBack() throws Exception {
+    OpExecutorImpl exec = getTestableOpExecutorImpl();
+    exec.setupServerAffinity(Boolean.TRUE);
+    expectedException.expect(TransactionException.class);
+    TXFailoverOp.execute(exec, 1);
+  }
+
+}

-- 
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <commits@geode.apache.org>'].

Reply via email to