HBASE-19391 Calling HRegion#initializeRegionInternals from a region replica can still re-create a region directory
This commit is contained in:
parent
c5e692c1dc
commit
9e7e58d551
|
@ -980,8 +980,10 @@ public class HRegionFileSystem {
|
|||
public static HRegionFileSystem createRegionOnFileSystem(final Configuration conf,
|
||||
final FileSystem fs, final Path tableDir, final HRegionInfo regionInfo) throws IOException {
|
||||
HRegionFileSystem regionFs = new HRegionFileSystem(conf, fs, tableDir, regionInfo);
|
||||
Path regionDir = regionFs.getRegionDir();
|
||||
|
||||
// We only create a .regioninfo and the region directory if this is the default region replica
|
||||
if (regionInfo.getReplicaId() == HRegionInfo.DEFAULT_REPLICA_ID) {
|
||||
Path regionDir = regionFs.getRegionDir();
|
||||
if (fs.exists(regionDir)) {
|
||||
LOG.warn("Trying to create a region that already exists on disk: " + regionDir);
|
||||
throw new IOException("The specified region already exists on disk: " + regionDir);
|
||||
|
@ -994,14 +996,13 @@ public class HRegionFileSystem {
|
|||
}
|
||||
|
||||
// Write HRI to a file in case we need to recover hbase:meta
|
||||
// Only primary replicas should write region info
|
||||
if (regionInfo.getReplicaId() == HRegionInfo.DEFAULT_REPLICA_ID) {
|
||||
regionFs.writeRegionInfoOnFilesystem(false);
|
||||
return regionFs;
|
||||
} else {
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Skipping creation of .regioninfo file for " + regionInfo);
|
||||
}
|
||||
return regionFs;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue