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

kturner 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 d766696152 improves TabletServerGivesUpIT (#4290)
d766696152 is described below

commit d7666961522c595ac6e8c408377c1c1664e62ee2
Author: Keith Turner <ktur...@apache.org>
AuthorDate: Thu Feb 22 10:24:03 2024 -0500

    improves TabletServerGivesUpIT (#4290)
    
    TabletServerGivesUpIT tests that a tserver will eventually die when it
    can not write to a walog.  For walog write failures to occur, there must
    be some thread in the tserver trying to write to the tserver. Changes in
    elasticity have made it where the activitiy this test was doing did not
    always cause a walog write.  This change is an attempt to improve the
    chance of a tserver thread attempting a walog write after DFS is killed.
---
 .../accumulo/test/TabletServerGivesUpIT.java       | 30 ++++++++++++++++------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git 
a/test/src/main/java/org/apache/accumulo/test/TabletServerGivesUpIT.java 
b/test/src/main/java/org/apache/accumulo/test/TabletServerGivesUpIT.java
index 2c023859e7..ae4009ee07 100644
--- a/test/src/main/java/org/apache/accumulo/test/TabletServerGivesUpIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/TabletServerGivesUpIT.java
@@ -21,16 +21,15 @@ package org.apache.accumulo.test;
 import static java.util.concurrent.TimeUnit.SECONDS;
 
 import java.time.Duration;
-import java.util.TreeSet;
 import java.util.concurrent.atomic.AtomicReference;
 
 import org.apache.accumulo.core.client.Accumulo;
 import org.apache.accumulo.core.client.AccumuloClient;
 import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.Mutation;
 import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl;
 import org.apache.accumulo.test.functional.ConfigurableMacBase;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.io.Text;
 import org.junit.jupiter.api.Test;
 
 // ACCUMULO-2480
@@ -60,25 +59,40 @@ public class TabletServerGivesUpIT extends 
ConfigurableMacBase {
       }
       final String tableName = getUniqueNames(1)[0];
       client.tableOperations().create(tableName);
+
+      // do an initial write to host the tablet and get its location in cache 
as we may not be able
+      // to read the metadata table later
+      try (var writer = client.createBatchWriter(tableName)) {
+        Mutation m = new Mutation("001");
+        m.put("a", "b", "c");
+        writer.addMutation(m);
+      }
+
       // Kill dfs
       cluster.getMiniDfs().shutdown();
       // ask the tserver to do something
       final AtomicReference<Exception> ex = new AtomicReference<>();
-      Thread splitter = new Thread(() -> {
+      Thread backgroundWriter = new Thread(() -> {
         try {
-          TreeSet<Text> splits = new TreeSet<>();
-          splits.add(new Text("X"));
-          client.tableOperations().addSplits(tableName, splits);
+          for (int i = 0; i < 100; i++) {
+            // These writes should cause the tserver to attempt to write to 
walog, which should
+            // repeatedly fail. Relying on the client side cache to have the 
tablet location so the
+            // writes make it to the tserver where the wal write fails.
+            try (var writer = client.createBatchWriter(tableName)) {
+              Mutation m = new Mutation("001");
+              m.put("a", "b", "c");
+              writer.addMutation(m);
+            }
+          }
         } catch (Exception e) {
           ex.set(e);
         }
       });
-      splitter.start();
+      backgroundWriter.start();
       // wait for the tserver to give up on writing to the WAL
       while (client.instanceOperations().getTabletServers().size() == 1) {
         Thread.sleep(SECONDS.toMillis(1));
       }
     }
   }
-
 }

Reply via email to