[ 
https://issues.apache.org/jira/browse/GEODE-7591?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17129813#comment-17129813
 ] 

ASF GitHub Bot commented on GEODE-7591:
---------------------------------------

kirklund commented on a change in pull request #5182:
URL: https://github.com/apache/geode/pull/5182#discussion_r437730502



##########
File path: 
geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/ClusterDistributionManagerDUnitTest.java
##########
@@ -370,6 +377,36 @@ public void testWaitForViewInstallation() {
         .untilAsserted(() -> 
assertThat(waitForViewInstallationDone.get()).isTrue());
   }
 
+  /**
+   * show that waitForViewInstallation works as expected when distribution 
manager is closed
+   * while waiting for the latest membership view to install
+   */
+  @Test
+  public void testWaitForViewInstallationDisconnectDS() {
+    InternalDistributedSystem system = getSystem();
+    ClusterDistributionManager dm = (ClusterDistributionManager) 
system.getDM();
+    MembershipView<InternalDistributedMember> view = 
dm.getDistribution().getView();
+
+    CyclicBarrier cyclicBarrier = new CyclicBarrier(2);
+    Future future = executorService.submit(() -> {
+      try {
+        cyclicBarrier.await(getTimeout().toMillis(), TimeUnit.MILLISECONDS);
+        dm.waitForViewInstallation(view.getViewId() + 1);
+      } catch (InterruptedException | BrokenBarrierException | 
TimeoutException e) {
+        errorCollector.addError(e);
+      }
+    });
+
+    try {
+      cyclicBarrier.await(getTimeout().toMillis(), TimeUnit.MILLISECONDS);
+      system.disconnect();
+      future.get(getTimeout().toMillis(), TimeUnit.MILLISECONDS);
+    } catch (InterruptedException | TimeoutException | ExecutionException

Review comment:
       You can delete the catch-block and use of errorCollector in the main 
thread. You only need to do that inside the Runnable that you submitted. From 
line 400 on, it's better to just let the Exceptions percolate out of the test 
method and let junit catch it.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> potential hang
> --------------
>
>                 Key: GEODE-7591
>                 URL: https://issues.apache.org/jira/browse/GEODE-7591
>             Project: Geode
>          Issue Type: Improvement
>          Components: membership
>            Reporter: Bruce J Schuchardt
>            Assignee: Jakov Varenina
>            Priority: Major
>
> This method in ClusterDistributionManager waits for a new membership view to 
> be installed, but if the cache is being closed while waiting the method could 
> hang because it only checks for cache closure if the object it's waiting on 
> is notified.  We should change the wait() to have a timeout so that the 
> `stopper` is polled periodically
> {code:java}
> void waitForViewInstallation(long id) throws InterruptedException {
>   if (id <= membershipViewIdAcknowledged) {
>     return;
>   }
>   synchronized (membershipViewIdGuard) {
>     while (membershipViewIdAcknowledged < id && 
> !stopper.isCancelInProgress()) {
>       if (logger.isDebugEnabled()) {
>         logger.debug("waiting for view {}.  Current DM view processed by all 
> listeners is {}", id,
>             membershipViewIdAcknowledged);
>       }
>       membershipViewIdGuard.wait();
>     }
>   }
> }
>  {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to