[
https://issues.apache.org/jira/browse/GEODE-2275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16330770#comment-16330770
]
ASF GitHub Bot commented on GEODE-2275:
---------------------------------------
nreich closed pull request #1298: GEODE-2275: Remove async creation of shared
static resource
URL: https://github.com/apache/geode/pull/1298
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/geode-core/src/test/java/org/apache/geode/internal/cache/ClearTXLockingDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/ClearTXLockingDUnitTest.java
index a2ea1454cc..a270675ad1 100644
---
a/geode-core/src/test/java/org/apache/geode/internal/cache/ClearTXLockingDUnitTest.java
+++
b/geode-core/src/test/java/org/apache/geode/internal/cache/ClearTXLockingDUnitTest.java
@@ -24,8 +24,8 @@
import java.util.Map;
import java.util.concurrent.CountDownLatch;
-import org.apache.logging.log4j.Logger;
import org.assertj.core.api.JUnitSoftAssertions;
+import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
@@ -34,22 +34,15 @@
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.CacheEvent;
import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.cache.CacheTransactionManager;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.RegionFactory;
import org.apache.geode.cache.RegionShortcut;
import org.apache.geode.cache.Scope;
-import org.apache.geode.distributed.DistributedMember;
import
org.apache.geode.distributed.internal.membership.InternalDistributedMember;
-import org.apache.geode.internal.logging.LogService;
import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.SerializableCallable;
-import org.apache.geode.test.dunit.SerializableRunnable;
-import org.apache.geode.test.dunit.SerializableRunnableIF;
import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
import org.apache.geode.test.junit.categories.DistributedTest;
-import org.apache.geode.test.junit.categories.FlakyTest;
/**
* Test class to verify proper locking interaction between transactions and
the CLEAR region
@@ -76,46 +69,44 @@
* processing is complete before clearing the region. Failure to do so,
would result in region
* inconsistencies.
*/
- VM vm0, vm1, opsVM, regionVM;
+ private static final String THE_KEY = "theKey";
+ private static final String THE_VALUE = "theValue";
+ private static final int NUMBER_OF_PUTS = 2;
+ private static final String REGION_NAME1 = "testRegion1";
+ private static final String REGION_NAME2 = "testRegion2";
static Cache cache;
-
- ArmLockHook theArmHook;
-
- DistributedMember vm0ID, vm1ID;
-
- static CacheTransactionManager txmgr;
-
- static final String THE_KEY = "theKey";
- static final String THE_VALUE = "theValue";
- static final int NUMBER_OF_PUTS = 2;
-
- static final String REGION_NAME1 = "testRegion1";
- static final String REGION_NAME2 = "testRegion2";
-
static CountDownLatch opsLatch;
- static CountDownLatch regionLatch;
- static CountDownLatch verifyLatch;
+ private static CountDownLatch regionLatch;
+ private static CountDownLatch verifyLatch;
- private static final Logger logger = LogService.getLogger();
+ private VM vm0;
+ private VM vm1;
+ private VM opsVM;
+ private VM regionVM;
+
+ @Before
+ public void setup() {
+ Host host = Host.getHost(0);
+ vm0 = host.getVM(0);
+ vm1 = host.getVM(1);
- // test methods
+ createCache(vm0);
+ createCache(vm1);
+ }
@Test
- public void testPutWithClearSameVM() throws InterruptedException {
- getVMs();
+ public void testPutWithClearSameVM() {
setupRegions(vm0, vm0);
setClearHook(REGION_NAME1, opsVM, regionVM);
- performTestAndCheckResults(putOperationsTest);
+ performTestAndCheckResults();
}
- @Category(FlakyTest.class) // GEODE-2275
@Test
- public void testPutWithClearDifferentVM() throws InterruptedException {
- getVMs();
+ public void testPutWithClearDifferentVM() {
setupRegions(vm0, vm1);
setClearHook(REGION_NAME1, opsVM, regionVM);
- performTestAndCheckResults(putOperationsTest);
+ performTestAndCheckResults();
}
/*
@@ -124,20 +115,18 @@ public void testPutWithClearDifferentVM() throws
InterruptedException {
*/
@Ignore
@Test
- public void testPutWithCloseSameVM() throws InterruptedException {
- getVMs();
+ public void testPutWithCloseSameVM() {
setupRegions(vm0, vm0);
setCloseHook(REGION_NAME1, opsVM, regionVM);
- performTestAndCheckResults(putOperationsTest);
+ performTestAndCheckResults();
}
@Ignore
@Test
- public void testPutWithCloseDifferentVM() throws InterruptedException {
- getVMs();
+ public void testPutWithCloseDifferentVM() {
setupRegions(vm0, vm1);
setCloseHook(REGION_NAME1, opsVM, regionVM);
- performTestAndCheckResults(putOperationsTest);
+ performTestAndCheckResults();
}
/*
@@ -146,20 +135,18 @@ public void testPutWithCloseDifferentVM() throws
InterruptedException {
*/
@Ignore
@Test
- public void testPutWithDestroyRegionSameVM() throws InterruptedException {
- getVMs();
+ public void testPutWithDestroyRegionSameVM() {
setupRegions(vm0, vm0);
setDestroyRegionHook(REGION_NAME1, opsVM, regionVM);
- performTestAndCheckResults(putOperationsTest);
+ performTestAndCheckResults();
}
@Ignore
@Test
- public void testPutWithDestroyRegionDifferentVM() throws
InterruptedException {
- getVMs();
+ public void testPutWithDestroyRegionDifferentVM() {
setupRegions(vm0, vm1);
setDestroyRegionHook(REGION_NAME1, opsVM, regionVM);
- performTestAndCheckResults(putOperationsTest);
+ performTestAndCheckResults();
}
// Local methods
@@ -167,10 +154,9 @@ public void testPutWithDestroyRegionDifferentVM() throws
InterruptedException {
/*
* This method executes a runnable test and then checks for region
consistency
*/
- private void performTestAndCheckResults(SerializableRunnable operationsTest)
- throws InterruptedException {
+ private void performTestAndCheckResults() {
try {
- runLockingTest(opsVM, operationsTest);
+ opsVM.invoke(this::putOperationsTest);
checkForConsistencyErrors(REGION_NAME1);
checkForConsistencyErrors(REGION_NAME2);
} finally {
@@ -178,15 +164,6 @@ private void
performTestAndCheckResults(SerializableRunnable operationsTest)
}
}
- /*
- * We will be using 2 vms. One for the transaction and one for the clear
- */
- private void getVMs() {
- Host host = Host.getHost(0);
- vm0 = host.getVM(0);
- vm1 = host.getVM(1);
- }
-
/*
* Set which vm will perform the transaction and which will perform the
region operation and
* create the regions on the vms
@@ -194,36 +171,21 @@ private void getVMs() {
private void setupRegions(VM opsTarget, VM regionTarget) {
opsVM = opsTarget;
regionVM = regionTarget;
- vm0ID = createCache(vm0);
- vm1ID = createCache(vm1);
vm0.invoke(() -> createRegion(REGION_NAME1));
vm0.invoke(() -> createRegion(REGION_NAME2));
vm1.invoke(() -> createRegion(REGION_NAME1));
vm1.invoke(() -> createRegion(REGION_NAME2));
}
- /*
- * Invoke a runnable on the operations vm
- */
- private void runLockingTest(VM vm, SerializableRunnableIF theTest) {
- vm.invoke(theTest);
+ private void putOperationsTest() {
+ opsVM.invoke(() -> doPuts(getCache(), regionVM));
}
- /*
- * Runnable used to invoke the actual test
- */
- SerializableRunnable putOperationsTest = new SerializableRunnable("perform
PUT") {
- @Override
- public void run() {
- opsVM.invoke(() -> doPuts(getCache(), regionVM));
- }
- };
-
/*
* Set arm hook to detect when region operation is attempting to acquire
write lock and stage the
* clear that will be released half way through commit processing.
*/
- public void setClearHook(String rname, VM whereOps, VM whereClear) {
+ private void setClearHook(String rname, VM whereOps, VM whereClear) {
whereOps.invoke(() -> setArmHook(rname));
whereClear.invokeAsync(() -> stageClear(rname, whereOps));
}
@@ -235,7 +197,8 @@ public void setClearHook(String rname, VM whereOps, VM
whereClear) {
* perform region verification.
*/
private static void stageClear(String rname, VM whereOps) throws
InterruptedException {
- regionOperationWait();
+ regionLatch = new CountDownLatch(1);
+ regionOperationWait(regionLatch);
LocalRegion r = (LocalRegion) cache.getRegion(rname);
r.clear();
whereOps.invoke(() -> releaseVerify());
@@ -244,25 +207,27 @@ private static void stageClear(String rname, VM whereOps)
throws InterruptedExce
/*
* Set and stage method for close and destroy are the same as clear
*/
- public void setCloseHook(String rname, VM whereOps, VM whereClear) {
+ private void setCloseHook(String rname, VM whereOps, VM whereClear) {
whereOps.invoke(() -> setArmHook(rname));
whereClear.invokeAsync(() -> stageClose(rname, whereOps));
}
private static void stageClose(String rname, VM whereOps) throws
InterruptedException {
- regionOperationWait();
+ regionLatch = new CountDownLatch(1);
+ regionOperationWait(regionLatch);
LocalRegion r = (LocalRegion) cache.getRegion(rname);
r.close();
whereOps.invoke(() -> releaseVerify());
}
- public void setDestroyRegionHook(String rname, VM whereOps, VM whereClear) {
+ private void setDestroyRegionHook(String rname, VM whereOps, VM whereClear) {
whereOps.invoke(() -> setArmHook(rname));
whereClear.invokeAsync(() -> stageDestroyRegion(rname, whereOps));
}
private static void stageDestroyRegion(String rname, VM whereOps) throws
InterruptedException {
- regionOperationWait();
+ regionLatch = new CountDownLatch(1);
+ regionOperationWait(regionLatch);
LocalRegion r = (LocalRegion) cache.getRegion(rname);
r.destroyRegion();
whereOps.invoke(() -> releaseVerify());
@@ -272,16 +237,16 @@ private static void stageDestroyRegion(String rname, VM
whereOps) throws Interru
* Set the abstract region map lock hook to detect attempt to acquire write
lock by region
* operation.
*/
- public void setArmHook(String rname) {
+ private void setArmHook(String rname) {
LocalRegion r = (LocalRegion) cache.getRegion(rname);
- theArmHook = new ArmLockHook();
+ ArmLockHook theArmHook = new ArmLockHook();
((AbstractRegionMap) r.entries).setARMLockTestHook(theArmHook);
}
/*
* Cleanup arm lock hook by setting it null
*/
- public void resetArmHook(String rname) {
+ private void resetArmHook(String rname) {
LocalRegion r = (LocalRegion) cache.getRegion(rname);
((AbstractRegionMap) r.entries).setARMLockTestHook(null);
}
@@ -289,9 +254,11 @@ public void resetArmHook(String rname) {
/*
* Wait to be notified it is time to perform region operation (i.e. CLEAR)
*/
- private static void regionOperationWait() throws InterruptedException {
- regionLatch = new CountDownLatch(1);
- regionLatch.await();
+ private static void regionOperationWait(CountDownLatch latch) throws
InterruptedException {
+ latch.await();
+ /*
+ * regionLatch = new CountDownLatch(1); regionLatch.await();
+ */
}
/*
@@ -342,32 +309,28 @@ private static void releaseVerify() {
}
private InternalDistributedMember createCache(VM vm) {
- return (InternalDistributedMember) vm.invoke(new
SerializableCallable<Object>() {
- public Object call() {
- cache = getCache(new CacheFactory().set("conserve-sockets", "true"));
- return getSystem().getDistributedMember();
- }
+ return vm.invoke(() -> {
+ cache = getCache(new CacheFactory().set("conserve-sockets", "true"));
+ return getSystem().getDistributedMember();
});
}
private static void createRegion(String rgnName) {
- RegionFactory<Object, Object> rf =
cache.createRegionFactory(RegionShortcut.REPLICATE);
- rf.setConcurrencyChecksEnabled(true);
- rf.setScope(Scope.DISTRIBUTED_ACK);
- rf.create(rgnName);
+ RegionFactory<Object, Object> factory =
cache.createRegionFactory(RegionShortcut.REPLICATE);
+ factory.setConcurrencyChecksEnabled(true);
+ factory.setScope(Scope.DISTRIBUTED_ACK);
+ factory.create(rgnName);
}
/*
* Get region contents from each member and verify they are consistent
*/
- private void checkForConsistencyErrors(String rname) {
- Map<Object, Object> r0Contents =
- (Map<Object, Object>) vm0.invoke(() -> getRegionContents(rname));
- Map<Object, Object> r1Contents =
- (Map<Object, Object>) vm1.invoke(() -> getRegionContents(rname));
+ private void checkForConsistencyErrors(String regionName) {
+ Map<Object, Object> r0Contents = vm0.invoke(() ->
getRegionContents(regionName));
+ Map<Object, Object> r1Contents = vm1.invoke(() ->
getRegionContents(regionName));
for (int i = 0; i < NUMBER_OF_PUTS; i++) {
- String theKey = rname + THE_KEY + i;
+ String theKey = regionName + THE_KEY + i;
if (r0Contents.containsKey(theKey)) {
softly.assertThat(r1Contents.get(theKey))
.as("region contents are not consistent for key %s", theKey)
@@ -395,12 +358,12 @@ private void checkForConsistencyErrors(String rname) {
* processing, release the region operation.
*/
static class CommitTestCallback implements Runnable {
- VM whereRegionOperation;
- static int callCount;
+ private VM whereRegionOperation;
+ private int callCount;
/* entered twice for each put lap since there are 2 regions */
- static int releasePoint = NUMBER_OF_PUTS;
+ private int releasePoint = NUMBER_OF_PUTS;
- public CommitTestCallback(VM whereRegion) {
+ CommitTestCallback(VM whereRegion) {
whereRegionOperation = whereRegion;
callCount = 0;
}
@@ -422,10 +385,6 @@ public void run() {
* occurring. Before this occurs, resume commit processing.
*/
public class ArmLockHook extends ARMLockTestHookAdapter {
- int txCalls = 0;
- int releasePoint = NUMBER_OF_PUTS / 2;
- CountDownLatch putLatch = new CountDownLatch(1);
-
@Override
public void beforeLock(LocalRegion owner, CacheEvent event) {
if (event != null) {
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> CI Failure: ClearTXLockingDUnitTest.testPutWithClearDifferentVM
> ---------------------------------------------------------------
>
> Key: GEODE-2275
> URL: https://issues.apache.org/jira/browse/GEODE-2275
> Project: Geode
> Issue Type: Bug
> Components: regions, transactions
> Reporter: Eric Shu
> Assignee: Nick Reich
> Priority: Major
> Labels: ci, flaky, pull-request-available
> Fix For: 1.5.0
>
>
> org.apache.geode.internal.cache.ClearTXLockingDUnitTest >
> testPutWithClearDifferentVM FAILED
> org.apache.geode.test.dunit.RMIException: While invoking
> org.apache.geode.internal.cache.ClearTXLockingDUnitTest$1.run in VM 0 running
> on Host d7fcb695b430 with 4 VMs
> at org.apache.geode.test.dunit.VM.invoke(VM.java:344)
> at org.apache.geode.test.dunit.VM.invoke(VM.java:314)
> at org.apache.geode.test.dunit.VM.invoke(VM.java:259)
> at
> org.apache.geode.internal.cache.ClearTXLockingDUnitTest.runLockingTest(ClearTXLockingDUnitTest.java:206)
> at
> org.apache.geode.internal.cache.ClearTXLockingDUnitTest.performTestAndCheckResults(ClearTXLockingDUnitTest.java:170)
> at
> org.apache.geode.internal.cache.ClearTXLockingDUnitTest.testPutWithClearDifferentVM(ClearTXLockingDUnitTest.java:115)
> Caused by:
> org.apache.geode.test.dunit.RMIException: While invoking
> org.apache.geode.internal.cache.ClearTXLockingDUnitTest$1$$Lambda$21/402256214.run
> in VM 0 running on Host d7fcb695b430 with 4 VMs
> Caused by:
> org.apache.geode.test.dunit.RMIException: While invoking
> org.apache.geode.internal.cache.ClearTXLockingDUnitTest$$Lambda$24/1595591059.run
> in VM 1 running on Host d7fcb695b430 with 4 VMs
> at org.apache.geode.test.dunit.VM.invoke(VM.java:344)
> at org.apache.geode.test.dunit.VM.invoke(VM.java:314)
> at org.apache.geode.test.dunit.VM.invoke(VM.java:259)
> at
> org.apache.geode.internal.cache.ClearTXLockingDUnitTest.releaseRegionOperation(ClearTXLockingDUnitTest.java:324)
> at
> org.apache.geode.internal.cache.ClearTXLockingDUnitTest.access$100(ClearTXLockingDUnitTest.java:67)
> at
> org.apache.geode.internal.cache.ClearTXLockingDUnitTest$CommitTestCallback.run(ClearTXLockingDUnitTest.java:408)
> at
> org.apache.geode.internal.cache.TXState.applyChanges(TXState.java:796)
> at
> org.apache.geode.internal.cache.TXState.commit(TXState.java:468)
> at
> org.apache.geode.internal.cache.TXStateProxyImpl.commit(TXStateProxyImpl.java:254)
> at
> org.apache.geode.internal.cache.TXManagerImpl.commit(TXManagerImpl.java:375)
> at
> org.apache.geode.internal.cache.ClearTXLockingDUnitTest.doPuts(ClearTXLockingDUnitTest.java:316)
> at
> org.apache.geode.internal.cache.ClearTXLockingDUnitTest.access$000(ClearTXLockingDUnitTest.java:67)
> Caused by:
> java.lang.NullPointerException
> at
> org.apache.geode.internal.cache.ClearTXLockingDUnitTest.lambda$releaseRegionOperation$b6506259$1(ClearTXLockingDUnitTest.java:324)
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)