Skip to content

Commit 8a0e71d

Browse files
committed
HBASE-29802 NPE when shutting down mini cluster cause tests hang (#7604) (#7612)
Remove the 'shutdownHook' in SingleProcessHBaseCluster where we close the FileSystem instance of a region server. Set DistributedFileSystem cache to false when creating MiniMRCluster so when shutting down MiniMRCluster it will not close the shared FileSystem instance. Also re-enable TestExportSnapshot. (cherry picked from commit d11ee6a) Signed-off-by: Nick Dimiduk <ndimiduk@apache.org> (cherry picked from commit 8841deb)
1 parent 22dd326 commit 8a0e71d

3 files changed

Lines changed: 6 additions & 49 deletions

File tree

hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshot.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
import org.junit.Before;
6565
import org.junit.BeforeClass;
6666
import org.junit.ClassRule;
67-
import org.junit.Ignore;
6867
import org.junit.Rule;
6968
import org.junit.Test;
7069
import org.junit.experimental.categories.Category;
@@ -80,7 +79,6 @@
8079
/**
8180
* Test Export Snapshot Tool
8281
*/
83-
@Ignore // HBASE-24493
8482
@Category({ VerySlowMapReduceTests.class, LargeTests.class })
8583
public class TestExportSnapshot {
8684

hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2832,10 +2832,14 @@ private void startMiniMapReduceCluster(final int servers) throws IOException {
28322832
jvmOpts + " --add-opens java.base/java.lang=ALL-UNNAMED");
28332833
}
28342834

2835+
// Disable fs cache for DistributedFileSystem, to avoid YARN RM close the shared FileSystem
2836+
// instance and cause trouble in HBase. See HBASE-29802 for more details.
2837+
JobConf mrClusterConf = new JobConf(conf);
2838+
mrClusterConf.setBoolean("fs.hdfs.impl.disable.cache", true);
28352839
// Allow the user to override FS URI for this map-reduce cluster to use.
28362840
mrCluster =
28372841
new MiniMRCluster(servers, FS_URI != null ? FS_URI : FileSystem.get(conf).getUri().toString(),
2838-
1, null, null, new JobConf(this.conf));
2842+
1, null, null, mrClusterConf);
28392843
JobConf jobConf = MapreduceTestingShim.getJobConf(mrCluster);
28402844
if (jobConf == null) {
28412845
jobConf = mrCluster.createJobConf();

hbase-server/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.util.List;
2525
import java.util.Set;
2626
import org.apache.hadoop.conf.Configuration;
27-
import org.apache.hadoop.fs.FileSystem;
2827
import org.apache.hadoop.hbase.client.RegionReplicaUtil;
2928
import org.apache.hadoop.hbase.master.HMaster;
3029
import org.apache.hadoop.hbase.regionserver.HRegion;
@@ -45,7 +44,6 @@
4544
import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService;
4645
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ClientService;
4746
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MasterService;
48-
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerStartupResponse;
4947

5048
/**
5149
* This class creates a single process HBase cluster. each server. The master uses the 'default'
@@ -122,7 +120,7 @@ public Configuration getConfiguration() {
122120
* only, not All filesystems as the FileSystem system exit hook does.
123121
*/
124122
public static class MiniHBaseClusterRegionServer extends HRegionServer {
125-
private Thread shutdownThread = null;
123+
126124
private User user = null;
127125
/**
128126
* List of RegionServers killed so far. ServerName also comprises startCode of a server, so any
@@ -137,20 +135,6 @@ public MiniHBaseClusterRegionServer(Configuration conf)
137135
this.user = User.getCurrent();
138136
}
139137

140-
/*
141-
* @param currentfs We return this if we did not make a new one.
142-
* @param uniqueName Same name used to help identify the created fs.
143-
* @return A new fs instance if we are up on DistributeFileSystem.
144-
*/
145-
146-
@Override
147-
protected void handleReportForDutyResponse(final RegionServerStartupResponse c)
148-
throws IOException {
149-
super.handleReportForDutyResponse(c);
150-
// Run this thread to shutdown our filesystem on way out.
151-
this.shutdownThread = new SingleFileSystemShutdownThread(getFileSystem());
152-
}
153-
154138
@Override
155139
public void run() {
156140
try {
@@ -163,12 +147,6 @@ public Object run() {
163147
});
164148
} catch (Throwable t) {
165149
LOG.error("Exception in run", t);
166-
} finally {
167-
// Run this on the way out.
168-
if (this.shutdownThread != null) {
169-
this.shutdownThread.start();
170-
Threads.shutdown(this.shutdownThread, 30000);
171-
}
172150
}
173151
}
174152

@@ -198,29 +176,6 @@ private void abortRegionServer(String reason, Throwable cause) {
198176
}
199177
}
200178

201-
/**
202-
* Alternate shutdown hook. Just shuts down the passed fs, not all as default filesystem hook
203-
* does.
204-
*/
205-
static class SingleFileSystemShutdownThread extends Thread {
206-
private final FileSystem fs;
207-
208-
SingleFileSystemShutdownThread(final FileSystem fs) {
209-
super("Shutdown of " + fs);
210-
this.fs = fs;
211-
}
212-
213-
@Override
214-
public void run() {
215-
try {
216-
LOG.info("Hook closing fs=" + this.fs);
217-
this.fs.close();
218-
} catch (IOException e) {
219-
LOG.warn("Running hook", e);
220-
}
221-
}
222-
}
223-
224179
private void init(final int nMasterNodes, final int numAlwaysStandByMasters,
225180
final int nRegionNodes, List<Integer> rsPorts, Class<? extends HMaster> masterClass,
226181
Class<? extends MiniHBaseCluster.MiniHBaseClusterRegionServer> regionserverClass)

0 commit comments

Comments
 (0)