You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JIRA: HDFS-17732. addExpectedReplicasToPending should add EC block expectedStorages in PendingReconstructionBlocks.
Now when a block commit , it should add expectedStorages into PendingReconstructionBlocks if datanode ibr is not sent from expected locations. And for a ec block group , only blkStriped.getRealTotalBlockNum() == expectedStorages.length will be added into PendingReconstructionBlocks.
The problem is that when an ec file size <= ecPolicy.getCellSize *(ecPolicy.getNumDataUnits()-1), it always will be blkStriped.getRealTotalBlockNum() < expectedStorages.length. This will lead to namenode generation reconstruction task first if other ibrs comme later.
For example:
(1) A EC file with XOR-2-1-1024k,file size <=1024k
(2) The file has one ec block and 3 replics (blk0,blk1,blk2) , and only blk0,blk2 has data because of file size <=1024k
(3) Namenode recived IBR0
(4) Client close file, now the file reach MinStorage and ec block commit
(5) Now blkStriped.getRealTotalBlockNum()=1 expectedStorages.length=3 ,so blk1,blk2 cannot add into PendingReconstructionBlocks
(6) Ec block complete and file close, because it has missing block so add into neededReconstruction
(7) Namenode generation ec reconstruction task and deliver to the datanode DN2
(8) Namenode recived IBR2 (DN2 blk2)
(9) Namenode recived new block (DN2 ec reconstruction task blk2')
(10) For ecPolicy, DN2 has two block blk2 ,blk2' , this increases the risk of data loss
(11) For other ecPolicy, on a same datanode may has two different replicas on one ec block group , and namenode will only record the later replica.
So the right way is:
(1) addExpectedReplicasToPending should add EC block expectedStorages in PendingReconstructionBlocks
(2) In order to reduce PendingReconstructionBlocks timeout, when a file close or ibr commes, we should remove block which has enough replicas from PendingReconstructionBlocks
slfan1989
changed the title
HDFS-17732. addExpectedReplicasToPending should add EC block expected…
HDFS-17732. addExpectedReplicasToPending should add EC block expectedStorages in PendingReconstructionBlocks.
Feb 20, 2025
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of PR
JIRA: HDFS-17732. addExpectedReplicasToPending should add EC block expectedStorages in PendingReconstructionBlocks.
Now when a block commit , it should add expectedStorages into PendingReconstructionBlocks if datanode ibr is not sent from expected locations. And for a ec block group , only blkStriped.getRealTotalBlockNum() == expectedStorages.length will be added into PendingReconstructionBlocks.
The problem is that when an ec file size <= ecPolicy.getCellSize *(ecPolicy.getNumDataUnits()-1), it always will be blkStriped.getRealTotalBlockNum() < expectedStorages.length. This will lead to namenode generation reconstruction task first if other ibrs comme later.
For example:

(1) A EC file with XOR-2-1-1024k,file size <=1024k
(2) The file has one ec block and 3 replics (blk0,blk1,blk2) , and only blk0,blk2 has data because of file size <=1024k
(3) Namenode recived IBR0
(4) Client close file, now the file reach MinStorage and ec block commit
(5) Now blkStriped.getRealTotalBlockNum()=1 expectedStorages.length=3 ,so blk1,blk2 cannot add into PendingReconstructionBlocks
(6) Ec block complete and file close, because it has missing block so add into neededReconstruction
(7) Namenode generation ec reconstruction task and deliver to the datanode DN2
(8) Namenode recived IBR2 (DN2 blk2)
(9) Namenode recived new block (DN2 ec reconstruction task blk2')
(10) For ecPolicy, DN2 has two block blk2 ,blk2' , this increases the risk of data loss
(11) For other ecPolicy, on a same datanode may has two different replicas on one ec block group , and namenode will only record the later replica.
So the right way is:
(1) addExpectedReplicasToPending should add EC block expectedStorages in PendingReconstructionBlocks
(2) In order to reduce PendingReconstructionBlocks timeout, when a file close or ibr commes, we should remove block which has enough replicas from PendingReconstructionBlocks