-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-29662 - Avoid regionDir/tableDir creation as part of .regioninfo file creation #7406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -764,7 +764,10 @@ private static void writeRegionInfoFileContent(final Configuration conf, final F | |
| // First check to get the permissions | ||
| FsPermission perms = CommonFSUtils.getFilePermissions(fs, conf, HConstants.DATA_FILE_UMASK_KEY); | ||
| // Write the RegionInfo file content | ||
| try (FSDataOutputStream out = FSUtils.create(conf, fs, regionInfoFile, perms, null)) { | ||
| // HBASE-29662: Fail .regioninfo file creation, if the region directory doesn't exist, | ||
| // avoiding silent masking of missing region directories during region initialization. | ||
| // The region directory should already exist when this method is called. | ||
| try (FSDataOutputStream out = FSUtils.create(conf, fs, regionInfoFile, perms, null, false)) { | ||
| out.write(content); | ||
| } | ||
| } | ||
|
|
@@ -848,6 +851,14 @@ private void writeRegionInfoOnFilesystem(final byte[] regionInfoContent, final b | |
| CommonFSUtils.delete(fs, tmpPath, true); | ||
| } | ||
|
|
||
| // Check parent (region) directory exists first to maintain HBASE-29662 protection | ||
| if (!fs.exists(getRegionDir())) { | ||
| throw new IOException("Region directory does not exist: " + getRegionDir()); | ||
| } | ||
| if (!fs.exists(getTempDir())) { | ||
| fs.mkdirs(getTempDir()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious, this was not covered so far?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was created previously as part of recursion in FS while creating file, now that I removed it and now we dont just blindly create all the directories that are present in path, we would need to create tmp directory explicitly |
||
| } | ||
|
|
||
| // Write HRI to a file in case we need to recover hbase:meta | ||
| writeRegionInfoFileContent(conf, fs, tmpPath, regionInfoContent); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment here why this change, providing the JIRA identifier. The reason not to recursively create directories is important, we don't want someone refactoring this code later to miss that.