HDDS-12233. Atomically import a container - #7934
Conversation
swamirishi
left a comment
There was a problem hiding this comment.
Thanks for working on the patch @ptlrs. This patch is incomplete from the sense where we are not updating the container state on disk and just doing it on memory and the problem could still persist on restarts.
| private static final String TEST_DESCRIPTOR_FILE_CONTENT = "!<KeyValueContainerData>\n" + | ||
| "checksum: 2215d39f2ae1de89fec837d18dc6387d8cba22fb5943cf4616f80c4b34e2edfe\n" + | ||
| "chunksPath: target/test-dir/MiniOzoneClusterImpl-23c1bb30-d86a-4f79-88dc-574d8259a5b3/ozone-meta/datanode-4/data-0/hdds/23c1bb30-d86a-4f79-88dc-574d8259a5b3/current/containerDir0/1/chunks\n" + | ||
| "containerDBType: RocksDB\n" + | ||
| "containerID: 1\n" + | ||
| "containerType: KeyValueContainer\n" + | ||
| "layOutVersion: 2\n" + | ||
| "maxSize: 5368709120\n" + | ||
| "metadata: {}\n" + | ||
| "metadataPath: target/test-dir/MiniOzoneClusterImpl-23c1bb30-d86a-4f79-88dc-574d8259a5b3/ozone-meta/datanode-4/data-0/hdds/23c1bb30-d86a-4f79-88dc-574d8259a5b3/current/containerDir0/1/metadata\n" + | ||
| "originNodeId: 25a48afa-f8d8-44ff-b268-642167e5354b\n" + | ||
| "originPipelineId: d7faca81-407f-4a50-a399-bd478c9795e5\n" + | ||
| "schemaVersion: '3'\n" + | ||
| "state: CLOSED"; |
There was a problem hiding this comment.
The dummy content for the descriptor file resulted in test failure as we now parse the descriptor file content and save to disk when performing the ATOMIC_MOVE. Updated the content to dummy parseable data.
|
Hi @ChenSammi, could you please take a look and review this PR. Thanks. |
sumitagrawl
left a comment
There was a problem hiding this comment.
@ptlrs given a comment to handle RECOVERING in code, plz have a look and it will simplify code
|
Hi @umamaheswararao, @swamirishi, @ChenSammi, @errose28, @kerneltime could you please review this PR. Thanks. |
|
The existing RECOVERING container handling will mark the failed import as unhealthy on restart. It will then be reported to SCM where it may or may not get deleted later if all the other replicas are also unhealthy. I think we should change this such that all RECOVERING containers (either Ratis imports or EC reconstructions) are deleted by the datanode on startup, since we know they are incomplete. cc @swamirishi |
swamirishi
left a comment
There was a problem hiding this comment.
@ptlrs thanks for the patch changes overall look good to me, excepting for some minor nitpicky comments. You may choose to address them in another follow up jira or the same, I am letting it on you to decide.
| return descriptorFileContent; | ||
| } | ||
|
|
||
| private void persistCustomContainerState(Container<KeyValueContainerData> container, byte[] descriptorContent, |
There was a problem hiding this comment.
Why explicitly Container ? Can this just not be any Container<? extends ContainerData>?
There was a problem hiding this comment.
Since this class implements ContainerPacker<KeyValueContainerData> I kept it consistent with the other methods. I have now made it generic since it's now part of the interface.
| } | ||
|
|
||
| KeyValueContainerData originalContainerData = | ||
| (KeyValueContainerData) ContainerDataYaml.readContainer(descriptorContent); |
There was a problem hiding this comment.
We needn't make this KeyValueContainerData specific. Do you think we can actually move this function ContainerPacker interface itself and make it a default function?
| if (VersionedDatanodeFeatures.isFinalized(HDDSLayoutFeature.HBASE_SUPPORT)) { | ||
| getLastChunkInfoTable().loadFromFile( | ||
| getTableDumpFile(getLastChunkInfoTable(), dumpDir)); | ||
| throws IOException, RocksDBException { |
There was a problem hiding this comment.
nit: Do you want to throw RockDBException here? Why not wrap RocksDBException inside IOException? Technically RocksDBException for ozone is actually like an IO error.
There was a problem hiding this comment.
Fixed by throwing IOException instead
| sstFileReader.open(tableDumpFile.getAbsolutePath()); | ||
| try (ManagedReadOptions managedReadOptions = new ManagedReadOptions(); | ||
| ManagedSstFileReaderIterator iterator = | ||
| ManagedSstFileReaderIterator.managed(sstFileReader.newIterator(managedReadOptions))) { |
There was a problem hiding this comment.
Are we sure there are no tombstones in this sst file?
There was a problem hiding this comment.
Can you confirm this? How we are generating this sst file.
There was a problem hiding this comment.
We dump the files by reading all the keys via an iterator so there should be no tombstones.
|
|
||
|
|
||
| @Test | ||
| public void testImportedContainerIsClosed() throws Exception { |
There was a problem hiding this comment.
Can we have miniOzoneCluster test case for the container cleanup on DN restart?
…-container-replication # Conflicts: # hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/TarContainerPacker.java
|
Hi @swamirishi, can you please review the latest changes. |
swamirishi
left a comment
There was a problem hiding this comment.
LGTM @ptlrs thanks for addressing all the review comments.
commented
Apr 1, 2025
|
Thanks for the patch @ptlrs and @sumitagrawl for reviewing the patch |
commented
Apr 1, 2025
|
Thank you for the extensive reviews @umamaheswararao @sumitagrawl @ChenSammi @swamirishi @errose28. |
What changes were proposed in this pull request?
This PR implements changes to atomically import a container.
RECOVERINGstate before it is imported.What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-12233
How was this patch tested?
CI: https://github.com/ptlrs/ozone/actions/runs/13518880080
Added some tests which check for the state of the container.