-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-8118. Fail container delete on non empty chunks dir #4367
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
7f4d566
a6e85ec
39a8185
0428ce6
6e041a2
e76e593
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 |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
|
|
||
| import java.io.File; | ||
| import java.io.IOException; | ||
| import java.nio.file.DirectoryStream; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.nio.file.Paths; | ||
|
|
@@ -159,6 +160,26 @@ public static void removeContainer(KeyValueContainerData containerData, | |
| FileUtils.deleteDirectory(containerMetaDataPath.getParentFile()); | ||
| } | ||
|
|
||
| /** | ||
| * Returns if there are no blocks in the container. | ||
| * @param containerData Container to check | ||
| * @param conf configuration | ||
| * @return true if the directory containing blocks is empty | ||
| * @throws IOException | ||
| */ | ||
| public static boolean noBlocksInContainer(KeyValueContainerData | ||
|
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. I think we want to check RocksDB and not chunks on disk. The latter may always be present due to orphaned writes. We only care about committed blocks which have entries in RocksDB.
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. The likelihood of having blocks written to disk but not in DN RocksDB will go down with https://issues.apache.org/jira/browse/HDDS-8117
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. I think we should check RocksDB in this PR and switch to using the directory check as part of HDDS-8117, or maybe wait until after HDDS-8138. Otherwise we may get some alarming false positives. In order to tell whether the exception is a false positive or not we would need to check RocksDB anyways, so I don't think the error message is useful without a RocksDB check given how the rest of the code works right now.
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. The read data is the block. We should work towards making sure blocks are written only if valid, and if they are on disk, we should err towards not cleaning them up. Even with HDDS-8138, I would like to keep this check in place. We can get HDDS-8117 in but while that is being worked on we should check in this fix to avoid any data loss which is the main motivation for this PR.
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. After offline discussion, we decided to keep this PR as is, since it is better than no check at all. A follow up PR will be coming shortly that will add a RocksDB check and log message here as well to help with debugging. |
||
| containerData) | ||
| throws IOException { | ||
| Preconditions.checkNotNull(containerData); | ||
| File chunksPath = new File(containerData.getChunksPath()); | ||
| Preconditions.checkArgument(chunksPath.isDirectory()); | ||
|
|
||
| try (DirectoryStream<Path> dir | ||
| = Files.newDirectoryStream(chunksPath.toPath())) { | ||
| return !dir.iterator().hasNext(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Parse KeyValueContainerData and verify checksum. Set block related | ||
| * metadata like block commit sequence id, block count, bytes used and | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.