From commits-return-27237-archive-asf-public=cust-asf.ponee.io@geode.apache.org Mon Jun 11 20:21:04 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 70075180670 for ; Mon, 11 Jun 2018 20:21:03 +0200 (CEST) Received: (qmail 48823 invoked by uid 500); 11 Jun 2018 18:21:02 -0000 Mailing-List: contact commits-help@geode.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.apache.org Delivered-To: mailing list commits@geode.apache.org Received: (qmail 48810 invoked by uid 99); 11 Jun 2018 18:21:02 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Jun 2018 18:21:02 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 6033D80813; Mon, 11 Jun 2018 18:21:01 +0000 (UTC) Date: Mon, 11 Jun 2018 18:21:00 +0000 To: "commits@geode.apache.org" Subject: [geode] branch feature/GEODE-5312 updated: GEDOE-5312: Cleanup transaction if it is removed by the client tx failover. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <152874126058.1505.17647809508648204707@gitbox.apache.org> From: eshu11@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: geode X-Git-Refname: refs/heads/feature/GEODE-5312 X-Git-Reftype: branch X-Git-Oldrev: 1da8eb9259be5367aad70e1cb725067f3700a419 X-Git-Newrev: 9229467845c544cbcf2ecfcb210f6ae365995743 X-Git-Rev: 9229467845c544cbcf2ecfcb210f6ae365995743 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. eshu11 pushed a commit to branch feature/GEODE-5312 in repository https://gitbox.apache.org/repos/asf/geode.git The following commit(s) were added to refs/heads/feature/GEODE-5312 by this push: new 9229467 GEDOE-5312: Cleanup transaction if it is removed by the client tx failover. 9229467 is described below commit 9229467845c544cbcf2ecfcb210f6ae365995743 Author: eshu AuthorDate: Mon Jun 11 11:16:58 2018 -0700 GEDOE-5312: Cleanup transaction if it is removed by the client tx failover. Co-authored-by: Bradford D. Boyle --- .../apache/geode/internal/cache/TXManagerImpl.java | 17 ++++++++++++ .../org/apache/geode/internal/cache/TXState.java | 4 +++ .../geode/internal/cache/TXManagerImplTest.java | 30 ++++++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/TXManagerImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/TXManagerImpl.java index efe1a10..193b3f1 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/TXManagerImpl.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/TXManagerImpl.java @@ -1017,11 +1017,24 @@ public class TXManagerImpl implements CacheTransactionManager, MembershipListene */ public void unmasquerade(TXStateProxy tx) { if (tx != null) { + cleanupTransactionIfNotExist(tx); setTXState(null); tx.getLock().unlock(); } } + private void cleanupTransactionIfNotExist(TXStateProxy tx) { + synchronized (hostedTXStates) { + if (!hostedTXStates.containsKey(tx.getTxId())) { + // clean up the transaction if no longer the host of the transaction + // this could occur when a failover command removed the transaction. + if (tx.isRealDealLocal()) { + ((TXStateProxyImpl) tx).getLocalRealDeal().cleanup(); + } + } + } + } + /** * Cleanup the remote txState after commit and rollback * @@ -1858,4 +1871,8 @@ public class TXManagerImpl implements CacheTransactionManager, MembershipListene } } + Map getHostedTXStates() { + return hostedTXStates; + } + } diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/TXState.java b/geode-core/src/main/java/org/apache/geode/internal/cache/TXState.java index c321896..9768fb8 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/TXState.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/TXState.java @@ -2064,4 +2064,8 @@ public class TXState implements TXStateInterface { public DistributedMember getProxyServer() { return this.proxyServer; } + + boolean isClosed() { + return closed; + } } diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/TXManagerImplTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/TXManagerImplTest.java index 7af4918..5731631 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/TXManagerImplTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/TXManagerImplTest.java @@ -22,6 +22,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import java.util.concurrent.CountDownLatch; @@ -337,4 +338,33 @@ public class TXManagerImplTest { txMgr.unmasquerade(existingTx); } } + + @Test + public void txStateNotCleanedupIfNotRemovedFromHostedTxStatesMap() { + TXManagerImpl txManager = spy(txMgr); + tx1 = txManager.getOrSetHostedTXState(txid, msg); + TXStateProxyImpl txStateProxy = (TXStateProxyImpl) tx1; + assertNotNull(txStateProxy); + assertFalse(txStateProxy.getLocalRealDeal().isClosed()); + + txManager.masqueradeAs(tx1); + txManager.unmasquerade(tx1); + assertFalse(txStateProxy.getLocalRealDeal().isClosed()); + + } + + @Test + public void txStateCleanedupIfRemovedFromHostedTxStatesMap() { + TXManagerImpl txManager = spy(txMgr); + tx1 = txManager.getOrSetHostedTXState(txid, msg); + TXStateProxyImpl txStateProxy = (TXStateProxyImpl) tx1; + assertNotNull(txStateProxy); + assertFalse(txStateProxy.getLocalRealDeal().isClosed()); + + txManager.masqueradeAs(tx1); + // during TX failover, tx can be removed from the hostedTXStates map by FindRemoteTXMessage + txManager.getHostedTXStates().remove(txid); + txManager.unmasquerade(tx1); + assertTrue(txStateProxy.getLocalRealDeal().isClosed()); + } } -- To stop receiving notification emails like this one, please contact eshu11@apache.org.