ozone
ozone copied to clipboard
HDDS-10230. Preventing V3 Schema from Creating Container DB in the Wrong Location
What changes were proposed in this pull request?
Preventing V3 Schema from Creating Container DB in the Wrong Location.
- Currently, when the
HddsVolumecannot load the "V3 Schema Container DB", it will create a "V3 Schema Container DB" in the logged-in user's home directory (dbOptions.setCreateIfMissing(true);). If there are multiple abnormalHddsVolume, 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
new File(containerData.getVolume().getDbParentDir(), OzoneConsts.CONTAINER_DB_NAME);
will be
new File(null, OzoneConsts.CONTAINER_DB_NAME);
then
new File(null, OzoneConsts.CONTAINER_DB_NAME).getAbsolutePath()
will return ${user.dir}/container.db
java.io.File#getAbsolutePath:
/**
...
* 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:
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
Thanks @xichen01 for working on this. There are some test failures:
https://github.com/xichen01/ozone/actions/runs/7685544604/job/20943567917#step:6:11
(TestOzoneContainerWithTLS also failed for me locally.)
Thanks @xichen01 for the contribution.