HIVE-28820: HMS might only creates the external directory and not the managed directory - #6717
Open
DanielZhu58 wants to merge 1 commit into
Open
HIVE-28820: HMS might only creates the external directory and not the managed directory#6717DanielZhu58 wants to merge 1 commit into
DanielZhu58 wants to merge 1 commit into
Conversation
… managed directory
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What changes were proposed in this pull request?
This PR fixes CreateDatabaseHandler.java so that the managed directory for a database is always created, regardless of whether MANAGEDLOCATION is explicitly specified at database creation time.
Previously, dbMgdPath was only set when the user explicitly passed a managed location URI; otherwise it was left null, and the managed directory creation logic (guarded by if (dbMgdPath != null)) was skipped entirely. This PR changes dbMgdPath to fall back to the already-computed defaultDbMgdPath when no managed location is explicitly specified, so the managed directory is always created using either the user-specified or the default path.
As part of this fix, the duplicated directory-creation logic for the managed and external directories (each previously implemented as separate doAs + isDir + mkdirs blocks) has been consolidated into a single private helper method, createDbDirectory, parameterized by the target path, whether to run as the login (admin) user or the current user, and a label used for logging/error messages.
Why are the changes needed?
The correct behavior is for HMS to always create a managed directory path for a database, whether or not a managed location is explicitly specified — mirroring how the external directory is always created via a default fallback path. Without this fix, some databases end up with only an external directory and no managed directory, which can cause downstream failures for any operation that expects the managed directory to exist (e.g. copying files into it).
Does this PR introduce any user-facing change?
Yes. Previously, creating a database without an explicit MANAGEDLOCATION could result in no managed directory being created on the filesystem. After this change, the managed directory is always created at the default managed location if one is not explicitly specified.
How was this patch tested?
Unit tests and q tests.