xichen01 opened a new pull request, #6113:
URL: https://github.com/apache/ozone/pull/6113

   
   ## What changes were proposed in this pull request?
   Preventing V3 Schema from Creating Container DB in the Wrong Location. 
   
   - Currently, when the `HddsVolume` cannot load the "V3 Schema Container DB", 
it will create a "V3 Schema Container DB" in the logged-in user's home 
directory. If there are multiple abnormal `HddsVolume`, all the Containers from 
these abnormal Volumes will using the same DB.
   - For HddsVolume that loads the Container DB abnormally, we should just make 
it a Failed Volume.
   
   ### root cause
   When the `HddsVolume` load "V3 Schema Container DB" abnormally, the 
`containerData.getVolume().getDbParentDir()` will be null. 
   The
   ```java
   new File(containerData.getVolume().getDbParentDir(), 
OzoneConsts.CONTAINER_DB_NAME);
   ```
   will be
   ```java
   new File(null, OzoneConsts.CONTAINER_DB_NAME);
   ```
   then
   ```java
   new File(null, OzoneConsts.CONTAINER_DB_NAME).getAbsolutePath()
   ```
   will return `${user.dir}/container.db`
   
   java.io.File#getAbsolutePath:
   ```java
     /**
         ...
       * If this abstract pathname is the empty abstract pathname then
       * the pathname string of the current user directory, 
         ...
     **/
       public String getAbsolutePath() {
           return fs.resolve(this);
       }
   ```
   
   KeyValueContainerLocationUtil#getContainerDBFile:
   ```java
     public static File getContainerDBFile(KeyValueContainerData containerData) 
{
       if (containerData.hasSchema(OzoneConsts.SCHEMA_V3)) {
         return new File(containerData.getVolume().getDbParentDir(),
             OzoneConsts.CONTAINER_DB_NAME);
       }
       return getContainerDBFile(containerData.getMetadataPath(), 
containerData);
     }
   ```
   
   ## What is the link to the Apache JIRA
   https://issues.apache.org/jira/browse/HDDS-10230
   
   ## How was this patch tested?
   Unit Test
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to