Skip to content

Commit 994182b

Browse files
committed
HDDS-8882. Manage status of DeleteBlocksCommand in SCM to avoid sending duplicates to Datanode (apache#4988)
(cherry picked from commit 88e18e3)
1 parent 9c6a586 commit 994182b

15 files changed

Lines changed: 1268 additions & 190 deletions

File tree

hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/report/CommandStatusReportPublisher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ protected CommandStatusReportsProto getReport() {
7878
// If status is still pending then don't remove it from map as
7979
// CommandHandler will change its status when it works on this command.
8080
if (!cmdStatus.getStatus().equals(Status.PENDING)) {
81-
builder.addCmdStatus(cmdStatus.getProtoBufMessage());
8281
map.remove(key);
8382
}
83+
builder.addCmdStatus(cmdStatus.getProtoBufMessage());
8484
});
8585
return builder.getCmdStatusCount() > 0 ? builder.build() : null;
8686
}

hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/report/TestReportPublisher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ public void testCommandStatusPublisher() throws InterruptedException {
173173
.build();
174174
cmdStatusMap.put(obj1.getCmdId(), obj1);
175175
cmdStatusMap.put(obj2.getCmdId(), obj2);
176-
// We are not sending the commands whose status is PENDING.
177-
Assertions.assertEquals(1,
176+
// We will sending the commands whose status is PENDING and EXECUTED
177+
Assertions.assertEquals(2,
178178
((CommandStatusReportPublisher) publisher).getReport()
179179
.getCmdStatusCount(),
180180
"Should publish report with 2 status objects");

hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLog.java

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919

2020
import java.util.Set;
2121
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
22-
import org.apache.hadoop.hdds.protocol.proto
23-
.StorageContainerDatanodeProtocolProtos.ContainerBlocksDeletionACKProto
24-
.DeleteBlockTransactionResult;
2522
import org.apache.hadoop.hdds.protocol.proto
2623
.StorageContainerDatanodeProtocolProtos.DeletedBlocksTransaction;
2724
import org.apache.hadoop.hdds.utils.db.Table;
25+
import org.apache.hadoop.ozone.protocol.commands.SCMCommand;
2826

2927
import java.io.Closeable;
3028
import java.io.IOException;
@@ -88,14 +86,33 @@ void incrementCount(List<Long> txIDs)
8886
int resetCount(List<Long> txIDs) throws IOException;
8987

9088
/**
91-
* Commits a transaction means to delete all footprints of a transaction
92-
* from the log. This method doesn't guarantee all transactions can be
93-
* successfully deleted, it tolerate failures and tries best efforts to.
94-
* @param transactionResults - delete block transaction results.
95-
* @param dnID - ID of datanode which acknowledges the delete block command.
89+
* Records the creation of a transaction for a DataNode.
90+
*
91+
* @param dnId The identifier of the DataNode.
92+
* @param scmCmdId The ID of the SCM command.
93+
* @param dnTxSet Set of transaction IDs for the DataNode.
94+
*/
95+
void recordTransactionCreated(
96+
UUID dnId, long scmCmdId, Set<Long> dnTxSet);
97+
98+
/**
99+
* Handles the cleanup process when a DataNode is reported dead. This method
100+
* is responsible for updating or cleaning up the transaction records
101+
* associated with the dead DataNode.
102+
*
103+
* @param dnId The identifier of the dead DataNode.
104+
*/
105+
void onDatanodeDead(UUID dnId);
106+
107+
/**
108+
* Records the event of sending a block deletion command to a DataNode. This
109+
* method is called when a command is successfully dispatched to a DataNode,
110+
* and it helps in tracking the status of the command.
111+
*
112+
* @param dnId Details of the DataNode.
113+
* @param scmCommand The block deletion command sent.
96114
*/
97-
void commitTransactions(List<DeleteBlockTransactionResult> transactionResults,
98-
UUID dnID);
115+
void onSent(DatanodeDetails dnId, SCMCommand<?> scmCommand);
99116

100117
/**
101118
* Creates block deletion transactions for a set of containers,

0 commit comments

Comments
 (0)