Skip to content

Commit

Permalink
GEODE-5375: fix the test hang when a CommitFailedException happens (a…
Browse files Browse the repository at this point in the history
…pache#2101)

Co-authored-by: Finn Southerland <[email protected]>
  • Loading branch information
jinmeiliao and FSOUTHERLAND authored Jul 9, 2018
1 parent dbdbd7a commit bb79fdb
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@ public void run() {

AsyncInvocation[] asyncInvocations = new AsyncInvocation[servers.length];
for (int i = 0; i < servers.length; i++) {
asyncInvocations[i] = servers[i].invokeAsync(() -> performOps());
asyncInvocations[i] = servers[i].invokeAsync("perform ops", () -> performOps());
}

// this test uses the DUnit blackboard to coordinate actions between JVMs
@@ -117,11 +117,11 @@ public void run() {
// clobber the current lock grantor
VM vm = servers[i];
System.out.println("TEST: killing vm " + i);
vm.invoke("force disconnect", () -> forceDisconnect());
vm.invoke("force disconnect", () -> forceDisconnect(false));
asyncInvocations[i].join();
System.out.println("TEST: recreating vm " + i);
vm.invoke("create cache", () -> createCacheAndRegion());
asyncInvocations[i] = vm.invokeAsync(() -> performOps());
asyncInvocations[i] = vm.invokeAsync("perform ops", () -> performOps());

// move the grantor into the next VM to be clobbered
int nextServer = (i + 1) % (servers.length - 1);
@@ -147,9 +147,8 @@ public void run() {
}

} finally {

for (VM vm : servers) {
vm.invoke(() -> forceDisconnect());
vm.invoke("force disconnect", () -> forceDisconnect(true));
}

Throwable failure = null;
@@ -173,12 +172,14 @@ private void checkAsyncInvocations(AsyncInvocation[] asyncInvocations) {
}
}

public void forceDisconnect() throws Exception {
public void forceDisconnect(boolean ignoreLock) throws Exception {
Cache existingCache = basicGetCache();
synchronized (commitLock) {
committing = false;
while (!committing) {
commitLock.wait();
if (!ignoreLock) {
synchronized (commitLock) {
committing = false;
while (!committing) {
commitLock.wait();
}
}
}
if (existingCache != null && !existingCache.isClosed()) {

0 comments on commit bb79fdb

Please sign in to comment.