Skip to content

Commit d11ee6a

Browse files
authored
HBASE-29802 NPE when shutting down mini cluster cause tests hang (apache#7604)
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. Signed-off-by: Nick Dimiduk <ndimiduk@apache.org>
1 parent f35268a commit d11ee6a

4 files changed

Lines changed: 7 additions & 91 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
@@ -63,7 +63,6 @@
6363
import org.junit.Before;
6464
import org.junit.BeforeClass;
6565
import org.junit.ClassRule;
66-
import org.junit.Ignore;
6766
import org.junit.Rule;
6867
import org.junit.Test;
6968
import org.junit.experimental.categories.Category;
@@ -79,7 +78,6 @@
7978
/**
8079
* Test Export Snapshot Tool
8180
*/
82-
@Ignore // HBASE-24493
8381
@Category({ VerySlowMapReduceTests.class, LargeTests.class })
8482
public class TestExportSnapshot {
8583

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

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

2344+
// Disable fs cache for DistributedFileSystem, to avoid YARN RM close the shared FileSystem
2345+
// instance and cause trouble in HBase. See HBASE-29802 for more details.
2346+
JobConf mrClusterConf = new JobConf(conf);
2347+
mrClusterConf.setBoolean("fs.hdfs.impl.disable.cache", true);
23442348
// Allow the user to override FS URI for this map-reduce cluster to use.
23452349
mrCluster =
23462350
new MiniMRCluster(servers, FS_URI != null ? FS_URI : FileSystem.get(conf).getUri().toString(),
2347-
1, null, null, new JobConf(this.conf));
2351+
1, null, null, mrClusterConf);
23482352
JobConf jobConf = MapreduceTestingShim.getJobConf(mrCluster);
23492353
if (jobConf == null) {
23502354
jobConf = mrCluster.createJobConf();

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

Lines changed: 1 addition & 41 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.RegionInfoBuilder;
2928
import org.apache.hadoop.hbase.client.RegionReplicaUtil;
3029
import org.apache.hadoop.hbase.master.HMaster;
@@ -44,8 +43,6 @@
4443
import org.slf4j.Logger;
4544
import org.slf4j.LoggerFactory;
4645

47-
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerStartupResponse;
48-
4946
/**
5047
* This class creates a single process HBase cluster. each server. The master uses the 'default'
5148
* FileSystem. The RegionServers, if we are running on DistributedFilesystem, create a FileSystem
@@ -123,7 +120,7 @@ public Configuration getConfiguration() {
123120
* only, not All filesystems as the FileSystem system exit hook does.
124121
*/
125122
public static class MiniHBaseClusterRegionServer extends HRegionServer {
126-
private Thread shutdownThread = null;
123+
127124
private User user = null;
128125
/**
129126
* List of RegionServers killed so far. ServerName also comprises startCode of a server, so any
@@ -138,14 +135,6 @@ public MiniHBaseClusterRegionServer(Configuration conf)
138135
this.user = User.getCurrent();
139136
}
140137

141-
@Override
142-
protected void handleReportForDutyResponse(final RegionServerStartupResponse c)
143-
throws IOException {
144-
super.handleReportForDutyResponse(c);
145-
// Run this thread to shutdown our filesystem on way out.
146-
this.shutdownThread = new SingleFileSystemShutdownThread(getFileSystem());
147-
}
148-
149138
@Override
150139
public void run() {
151140
try {
@@ -158,12 +147,6 @@ public Object run() {
158147
});
159148
} catch (Throwable t) {
160149
LOG.error("Exception in run", t);
161-
} finally {
162-
// Run this on the way out.
163-
if (this.shutdownThread != null) {
164-
this.shutdownThread.start();
165-
Threads.shutdown(this.shutdownThread, 30000);
166-
}
167150
}
168151
}
169152

@@ -193,29 +176,6 @@ private void abortRegionServer(String reason, Throwable cause) {
193176
}
194177
}
195178

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

hbase-testing-util/src/main/java/org/apache/hadoop/hbase/MiniHBaseCluster.java

Lines changed: 1 addition & 47 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.RegionInfoBuilder;
2928
import org.apache.hadoop.hbase.client.RegionReplicaUtil;
3029
import org.apache.hadoop.hbase.master.HMaster;
@@ -43,8 +42,6 @@
4342
import org.slf4j.Logger;
4443
import org.slf4j.LoggerFactory;
4544

46-
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerStartupResponse;
47-
4845
/**
4946
* This class creates a single process HBase cluster. each server. The master uses the 'default'
5047
* FileSystem. The RegionServers, if we are running on DistributedFilesystem, create a FileSystem
@@ -123,7 +120,7 @@ public Configuration getConfiguration() {
123120
* only, not All filesystems as the FileSystem system exit hook does.
124121
*/
125122
public static class MiniHBaseClusterRegionServer extends HRegionServer {
126-
private Thread shutdownThread = null;
123+
127124
private User user = null;
128125
/**
129126
* List of RegionServers killed so far. ServerName also comprises startCode of a server, so any
@@ -138,20 +135,6 @@ public MiniHBaseClusterRegionServer(Configuration conf)
138135
this.user = User.getCurrent();
139136
}
140137

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

@@ -199,29 +176,6 @@ private void abortRegionServer(String reason, Throwable cause) {
199176
}
200177
}
201178

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

0 commit comments

Comments
 (0)