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

dlmarion pushed a commit to branch elasticity
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/elasticity by this push:
     new 335592c68d Resolved timeout issue in MemoryStarvedMajCIT (#4267)
335592c68d is described below

commit 335592c68deb4fa59e00decc4d3fd72251f2d963
Author: Dave Marion <dlmar...@apache.org>
AuthorDate: Thu Feb 15 14:33:06 2024 -0500

    Resolved timeout issue in MemoryStarvedMajCIT (#4267)
    
    It appears that the test was stopping the Compactors, but not
    waiting for their ZooKeeper locks to be removed, before moving
    on and checking the number of zookeeper locks. I think what was
    happening is that the test code moved forward thinking that the
    Compactors were stopped, but the Compactors were actually stopping
    after this point and during the next step in the test.
---
 .../util/compaction/ExternalCompactionUtil.java     |  2 +-
 .../miniclusterImpl/MiniAccumuloClusterControl.java |  4 ++++
 .../test/functional/MemoryStarvedMajCIT.java        | 21 ++++++++++++++++++---
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git 
a/core/src/main/java/org/apache/accumulo/core/util/compaction/ExternalCompactionUtil.java
 
b/core/src/main/java/org/apache/accumulo/core/util/compaction/ExternalCompactionUtil.java
index 697f079d40..0d42f659c8 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/util/compaction/ExternalCompactionUtil.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/util/compaction/ExternalCompactionUtil.java
@@ -114,7 +114,6 @@ public class ExternalCompactionUtil {
       ZooReader zooReader = context.getZooReader();
       List<String> groups = zooReader.getChildren(compactorGroupsPath);
       for (String group : groups) {
-        groupsAndAddresses.putIfAbsent(group, new ArrayList<>());
         try {
           List<String> compactors = zooReader.getChildren(compactorGroupsPath 
+ "/" + group);
           for (String compactor : compactors) {
@@ -124,6 +123,7 @@ public class ExternalCompactionUtil {
                 zooReader.getChildren(compactorGroupsPath + "/" + group + "/" 
+ compactor);
             if (!children.isEmpty()) {
               LOG.trace("Found live compactor {} ", compactor);
+              groupsAndAddresses.putIfAbsent(group, new ArrayList<>());
               
groupsAndAddresses.get(group).add(HostAndPort.fromString(compactor));
             }
           }
diff --git 
a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterControl.java
 
b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterControl.java
index 21e831c3e0..9bf50cff2e 100644
--- 
a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterControl.java
+++ 
b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterControl.java
@@ -519,6 +519,10 @@ public class MiniAccumuloClusterControl implements 
ClusterControl {
     stop(server, hostname);
   }
 
+  public List<Process> getCompactors(String resourceGroup) {
+    return compactorProcesses.get(resourceGroup);
+  }
+
   public List<Process> getTabletServers(String resourceGroup) {
     return tabletServerProcesses.get(resourceGroup);
   }
diff --git 
a/test/src/main/java/org/apache/accumulo/test/functional/MemoryStarvedMajCIT.java
 
b/test/src/main/java/org/apache/accumulo/test/functional/MemoryStarvedMajCIT.java
index 98222a5fa6..19723a5391 100644
--- 
a/test/src/main/java/org/apache/accumulo/test/functional/MemoryStarvedMajCIT.java
+++ 
b/test/src/main/java/org/apache/accumulo/test/functional/MemoryStarvedMajCIT.java
@@ -22,6 +22,7 @@ import static org.apache.accumulo.test.util.Wait.waitFor;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.util.List;
 import java.util.Map;
@@ -66,6 +67,7 @@ public class MemoryStarvedMajCIT extends 
SharedMiniClusterBase {
       cfg.getClusterServerConfiguration().setNumDefaultTabletServers(1);
       cfg.getClusterServerConfiguration().setNumDefaultScanServers(0);
       cfg.getClusterServerConfiguration().setNumDefaultCompactors(1);
+      cfg.setProperty(Property.INSTANCE_ZK_TIMEOUT, "15s");
       cfg.setProperty(Property.GENERAL_LOW_MEM_DETECTOR_INTERVAL, "5s");
       cfg.setProperty(Property.GENERAL_LOW_MEM_DETECTOR_THRESHOLD,
           Double.toString(MemoryStarvedScanIT.FREE_MEMORY_THRESHOLD));
@@ -132,10 +134,23 @@ public class MemoryStarvedMajCIT extends 
SharedMiniClusterBase {
 
       ClientContext ctx = (ClientContext) client;
 
-      // Stop the normal compactors and start the version that will consume
-      // and free memory when we need it to
-      getCluster().getClusterControl().stopAllServers(ServerType.COMPACTOR);
+      // Kill the normal compactors and wait until their addresses in ZK are 
cleared
+      
getCluster().getConfig().getClusterServerConfiguration().getCompactorConfiguration().keySet()
+          .forEach(resourceGroup -> {
+            List<Process> procs = 
getCluster().getClusterControl().getCompactors(resourceGroup);
+            for (int i = 0; i < procs.size(); i++) {
+              LOG.info("Stopping compactor process: {}", procs.get(i).pid());
+              try {
+                procs.get(i).destroyForcibly().waitFor();
+              } catch (InterruptedException e) {
+                fail("Interrupted trying to stop compactor process");
+              }
+            }
+            
getCluster().getClusterControl().getCompactors(resourceGroup).clear();
+          });
+      Wait.waitFor(() -> ExternalCompactionUtil.getCompactorAddrs(ctx).size() 
== 0, 60_000);
 
+      // Start the Compactors that will consume and free memory when we need 
it to
       getCluster().getClusterControl().start(ServerType.COMPACTOR, null, 1,
           MemoryConsumingCompactor.class);
       Wait.waitFor(() -> ExternalCompactionUtil.getCompactorAddrs(ctx).size() 
== 4, 60_000);

Reply via email to