Skip to content

Commit

Permalink
Fix race condition between IBR and Edit tailing on Standby
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny Becker committed Apr 4, 2024
1 parent d7157b4 commit 7556dbe
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,21 @@ void removeAllMessagesForDatanode(DatanodeDescriptor dn) {

void enqueueReportedBlock(DatanodeStorageInfo storageInfo, Block block,
ReplicaState reportedState) {
long genStamp = block.getGenerationStamp();
if (BlockIdManager.isStripedBlockID(block.getBlockId())) {
Block blkId = new Block(BlockIdManager.convertToStripedID(block
.getBlockId()));
getBlockQueue(blkId).add(
new ReportedBlockInfo(storageInfo, new Block(block), reportedState));
Queue<ReportedBlockInfo> queue = getBlockQueue(blkId);
queue.removeIf(rbi -> rbi.storageInfo.equals(storageInfo) &&
rbi.block.getGenerationStamp() < genStamp);
queue.add(new ReportedBlockInfo(storageInfo, new Block(block), reportedState));
} else {
block = new Block(block);
getBlockQueue(block).add(
new ReportedBlockInfo(storageInfo, block, reportedState));
Queue<ReportedBlockInfo> queue = getBlockQueue(block);
// Remove the existing reports for this block since they are probably older and out of date
queue.removeIf(rbi -> rbi.storageInfo.equals(storageInfo) &&
rbi.block.getGenerationStamp() < genStamp);
queue.add(new ReportedBlockInfo(storageInfo, block, reportedState));
}
count++;
}
Expand Down

0 comments on commit 7556dbe

Please sign in to comment.