Skip to content

Commit d766696

Browse files
authored
improves TabletServerGivesUpIT (apache#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.
1 parent e44f47c commit d766696

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

test/src/main/java/org/apache/accumulo/test/TabletServerGivesUpIT.java

+22-8
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,15 @@
2121
import static java.util.concurrent.TimeUnit.SECONDS;
2222

2323
import java.time.Duration;
24-
import java.util.TreeSet;
2524
import java.util.concurrent.atomic.AtomicReference;
2625

2726
import org.apache.accumulo.core.client.Accumulo;
2827
import org.apache.accumulo.core.client.AccumuloClient;
2928
import org.apache.accumulo.core.conf.Property;
29+
import org.apache.accumulo.core.data.Mutation;
3030
import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl;
3131
import org.apache.accumulo.test.functional.ConfigurableMacBase;
3232
import org.apache.hadoop.conf.Configuration;
33-
import org.apache.hadoop.io.Text;
3433
import org.junit.jupiter.api.Test;
3534

3635
// ACCUMULO-2480
@@ -60,25 +59,40 @@ public void test() throws Exception {
6059
}
6160
final String tableName = getUniqueNames(1)[0];
6261
client.tableOperations().create(tableName);
62+
63+
// do an initial write to host the tablet and get its location in cache as we may not be able
64+
// to read the metadata table later
65+
try (var writer = client.createBatchWriter(tableName)) {
66+
Mutation m = new Mutation("001");
67+
m.put("a", "b", "c");
68+
writer.addMutation(m);
69+
}
70+
6371
// Kill dfs
6472
cluster.getMiniDfs().shutdown();
6573
// ask the tserver to do something
6674
final AtomicReference<Exception> ex = new AtomicReference<>();
67-
Thread splitter = new Thread(() -> {
75+
Thread backgroundWriter = new Thread(() -> {
6876
try {
69-
TreeSet<Text> splits = new TreeSet<>();
70-
splits.add(new Text("X"));
71-
client.tableOperations().addSplits(tableName, splits);
77+
for (int i = 0; i < 100; i++) {
78+
// These writes should cause the tserver to attempt to write to walog, which should
79+
// repeatedly fail. Relying on the client side cache to have the tablet location so the
80+
// writes make it to the tserver where the wal write fails.
81+
try (var writer = client.createBatchWriter(tableName)) {
82+
Mutation m = new Mutation("001");
83+
m.put("a", "b", "c");
84+
writer.addMutation(m);
85+
}
86+
}
7287
} catch (Exception e) {
7388
ex.set(e);
7489
}
7590
});
76-
splitter.start();
91+
backgroundWriter.start();
7792
// wait for the tserver to give up on writing to the WAL
7893
while (client.instanceOperations().getTabletServers().size() == 1) {
7994
Thread.sleep(SECONDS.toMillis(1));
8095
}
8196
}
8297
}
83-
8498
}

0 commit comments

Comments
 (0)