-
Notifications
You must be signed in to change notification settings - Fork 537
HDDS-9915. [hsync] Interface to retrieve block info and finalize block in DN through ratis. #5783
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
Conversation
@ChenSammi @jojochuang, Please help to review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Please check out my comments:
@@ -376,8 +377,20 @@ public TransactionContext startTransaction(RaftClientRequest request) | |||
ctxt.setException(ioe); | |||
return ctxt; | |||
} | |||
if (proto.getCmdType() == Type.WriteChunk) { | |||
if (proto.getCmdType() == Type.PutBlock) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does PutBlock need change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to reject request from original client if there is any PUT block request after finalize block is called by recoverer client.
...tainer-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java
Outdated
Show resolved
Hide resolved
...tainer-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java
Outdated
Show resolved
Hide resolved
@@ -384,6 +413,10 @@ public String getDeletingBlockKeyPrefix() { | |||
return formatKey(DELETING_KEY_PREFIX); | |||
} | |||
|
|||
public String getFinalizeBlockKey() { | |||
return formatKey(""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing a key here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
store.getFinalizeBlocksTable(); | ||
|
||
FinalizeBlockList finalizeBlockList = | ||
finalizeBlocksTable.get(kvContainerData.getFinalizeBlockKey()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it looks a little strange. Assuming you fetch FinalizeBlockList regardless of their containers, you would get all finalize blocks, but FinalizeBlockList is a list of Long, it is unable to tell what containers the blocks belong too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect you want to use KeyValueContainerData.getBlockKey() to add prefix for different containers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would have loaded only container specific list as based on previous comment format key returns containerId as key in schema v3. Now i have changed key structure as previous comment..
...ervice/src/main/java/org/apache/hadoop/ozone/container/keyvalue/interfaces/ChunkManager.java
Show resolved
Hide resolved
hadoop-hdds/interface-client/src/main/proto/DatanodeClientProtocol.proto
Outdated
Show resolved
Hide resolved
...a/org/apache/hadoop/ozone/container/common/transport/server/ratis/ContainerStateMachine.java
Outdated
Show resolved
Hide resolved
} else { | ||
return TransactionContext.newBuilder() | ||
} else if (proto.getCmdType() == Type.FinalizeBlock) { | ||
containerController.addFinalizedBlock(proto.getContainerID(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot add the finalize block in startTransaction, otherwise there is chance that valid write chunk or put block in applyTransaction will be failed because of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are rejecting request only in startTransaction
and not in applyTransaction
. So once the request has passed in startTransaction I think it should succeed in applyTransaction.
In which case this can happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Currently finalized block is not checked in applyTransaction. Then it's fine.
FixedLengthStringCodec.get(), | ||
FinalizeBlockList.class, | ||
FinalizeBlockList.getCodec()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use list as value here. The list will have performance impact. For example, if there is 99 blocks already, then the 100th block comes, we need to persist the whole list with 100 elements in to RocksDB, the list introduces unnecessary bytes to write.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed storage as <ContainerId | LocalId, BlockData>. Since DatanodeTable iterator doesn't support. I store value as BlockData and currently used keyValueBlockIterator which can iterate through blocks. Is this fine to store or do you have any other suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about implement a new implementation of BlockIterator? Since only the local ID is useful, then the value can be just the local ID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added new implementation of BlockIterator and store value as localId only.
...tainer-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java
Outdated
Show resolved
Hide resolved
...r-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/ContainerController.java
Outdated
Show resolved
Hide resolved
...-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueContainerData.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/apache/hadoop/ozone/container/keyvalue/helpers/KeyValueContainerUtil.java
Outdated
Show resolved
Hide resolved
...-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueContainerData.java
Outdated
Show resolved
Hide resolved
hadoop-hdds/interface-client/src/main/proto/DatanodeClientProtocol.proto
Outdated
Show resolved
Hide resolved
...tainer-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java
Outdated
Show resolved
Hide resolved
.../org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestFinalizeBlock.java
Outdated
Show resolved
Hide resolved
.../org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestFinalizeBlock.java
Show resolved
Hide resolved
27a9d9f
to
a26fbb6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ashishkumar50 for the contribution, and @jojochuang for the review.
…k in DN through ratis. (apache#5783)
…k in DN through ratis. (apache#5783)
…k in DN through ratis. (apache#5783)
What changes were proposed in this pull request?
New interface in datanode to finalize block and return block info.
If the block is already finalized just return back the block info. Keep block info in memory for which there is a finalize request, so that no new WRITE CHUNK/PUT Block is accepted for that block.
Persist finalize block ID into new rocksdb column family.
Clear the memory and delete from rocksdb during container Close.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-9915
How was this patch tested?
Unit and Integration test