aryangupta1998 commented on code in PR #8767:
URL: https://github.com/apache/ozone/pull/8767#discussion_r2205750273
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java:
##########
@@ -326,9 +337,18 @@ public void close() {
}
private void getTransaction(DeletedBlocksTransaction tx,
- DatanodeDeletedBlockTransactions transactions,
- Set<ContainerReplica> replicas,
- Map<DatanodeID, Map<Long, CmdStatus>> commandStatus) {
+ DatanodeDeletedBlockTransactions
transactions,
+ Set<ContainerReplica> replicas,
+ Map<DatanodeID, Map<Long, CmdStatus>>
commandStatus) {
+
+ // Check if all replicas satisfy the maxBlocksPerDatanode condition
Review Comment:
```suggestion
// Ensure all DNs for this transaction are below their max block limit.
// If even one exceeds the limit, skip assigning this transaction.
```
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java:
##########
@@ -326,9 +337,18 @@ public void close() {
}
private void getTransaction(DeletedBlocksTransaction tx,
- DatanodeDeletedBlockTransactions transactions,
- Set<ContainerReplica> replicas,
- Map<DatanodeID, Map<Long, CmdStatus>> commandStatus) {
+ DatanodeDeletedBlockTransactions
transactions,
+ Set<ContainerReplica> replicas,
+ Map<DatanodeID, Map<Long, CmdStatus>>
commandStatus) {
+
+ // Check if all replicas satisfy the maxBlocksPerDatanode condition
+ if (!replicas.stream().allMatch(replica -> {
+ final DatanodeID datanodeID = replica.getDatanodeDetails().getID();
+ return transactions.getNumberOfBlocksForDatanode(datanodeID) <
maxDeleteBlocksPerDatanode;
+ })) {
+ return;
+ }
Review Comment:
This can lead to exceeding the per-DN block limit
(maxDeleteBlocksPerDatanode) because it only checks existing assigned blocks,
not potential new ones from the transaction(tx).
Let’s say:
A DN already has 95k blocks assigned for deletion.
tx.getLocalIDList().size() = 10k.
maxDeleteBlocksPerDatanode = 100k.
Then this transaction would still be allowed, resulting in 105k blocks
assigned, exceeding the limit.
```suggestion
if (!replicas.stream().allMatch(replica -> {
final DatanodeID datanodeID = replica.getDatanodeDetails().getID();
int existing = transactions.getNumberOfBlocksForDatanode(datanodeID);
int incoming = tx.getLocalIDList().size();
return existing + incoming <= maxDeleteBlocksPerDatanode;
})) {
return;
}
```
Let's also add a debug log when we skip the DN as maxDeleteBlocksPerDatanode
is crossed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]