This is an automated email from the ASF dual-hosted git repository.

ArafatKhan2198 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 0c93bc00e5d HDDS-17050. Recon task cursor advances past a batch that 
failed both attempts, so a restart soon after the failure can lose that batch. 
(#12093)
0c93bc00e5d is described below

commit 0c93bc00e5d37f4d6598ff3290acdd76a0ad6c8a
Author: Arafat2198 <[email protected]>
AuthorDate: Tue Nov 24 12:22:43 2026 +0530

    HDDS-17050. Recon task cursor advances past a batch that failed both 
attempts, so a restart soon after the failure can lose that batch. (#12093)
    
    Co-authored-by: Siyao Meng <[email protected]>
---
 .../ozone/recon/tasks/ReconTaskControllerImpl.java | 10 +++++++
 .../recon/tasks/TestReconTaskControllerImpl.java   | 34 ++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/ReconTaskControllerImpl.java
 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/ReconTaskControllerImpl.java
index d0470d1070a..e866cc571e2 100644
--- 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/ReconTaskControllerImpl.java
+++ 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/ReconTaskControllerImpl.java
@@ -553,6 +553,16 @@ private void processOMUpdateBatch(OMUpdateEventBatch 
events) {
       return;
     }
 
+    // A batch that failed both attempts only raises tasksFailed. The next 
sync drains this buffer and
+    // rebuilds from a checkpoint that already contains every queued batch. 
Applying the batches still
+    // waiting would move the task cursor up to the OmDeltaRequest cursor, so 
a restart before that
+    // rebuild would find nothing to redo and the failed batch would be lost.
+    if (hasTasksFailed()) {
+      LOG.debug("Skipping buffered OM update batch ending at sequence {} 
because a task has failed and " +
+          "reinitialization is pending.", events.getLastSequenceNumber());
+      return;
+    }
+
     Collection<NamedCallableTask<ReconOmTask.TaskResult>> tasks = new 
ArrayList<>();
     List<ReconOmTask.TaskResult> failedTasks = new ArrayList<>();
 
diff --git 
a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestReconTaskControllerImpl.java
 
b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestReconTaskControllerImpl.java
index 9d650f6e926..df3884c0703 100644
--- 
a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestReconTaskControllerImpl.java
+++ 
b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestReconTaskControllerImpl.java
@@ -287,6 +287,40 @@ public void testFailedTaskRetryLogic() throws Exception {
     assertEquals(Long.valueOf(100L), dbRecord.getLastUpdatedSeqNumber());
   }
 
+  @Test
+  public void testBatchesBehindFailedBatchDoNotAdvanceTaskCursor() throws 
Exception {
+    ReconOmTask reconOmTaskMock = getMockTask("MockTask");
+    when(reconOmTaskMock.process(any(OMUpdateEventBatch.class), anyMap()))
+        .thenReturn(new 
ReconOmTask.TaskResult.Builder().setTaskName("MockTask").setTaskSuccess(false).build())
+        .thenReturn(new 
ReconOmTask.TaskResult.Builder().setTaskName("MockTask").setTaskSuccess(false).build())
+        .thenReturn(new 
ReconOmTask.TaskResult.Builder().setTaskName("MockTask").setTaskSuccess(true).build());
+    reconTaskController.registerTask(reconOmTaskMock);
+
+    ReconTaskControllerImpl controller = (ReconTaskControllerImpl) 
reconTaskController;
+    controller.processReconEvent(eventBatch(100L));
+
+    assertTrue(controller.hasTasksFailed());
+    ReconTaskStatus failedStatus = reconTaskStatusDao.findById("MockTask");
+    assertEquals(0L, failedStatus.getLastUpdatedSeqNumber());
+
+    // This batch is already buffered behind the failed one and would succeed. 
It must not move the cursor.
+    controller.processReconEvent(eventBatch(200L));
+
+    ReconTaskStatus status = reconTaskStatusDao.findById("MockTask");
+    assertEquals(0L, status.getLastUpdatedSeqNumber());
+    verify(reconOmTaskMock, times(2)).process(any(), anyMap());
+  }
+
+  private OMUpdateEventBatch eventBatch(long sequenceNumber) {
+    OMUpdateEventBatch batch = mock(OMUpdateEventBatch.class);
+    when(batch.isEmpty()).thenReturn(false);
+    when(batch.getLastSequenceNumber()).thenReturn(sequenceNumber);
+    when(batch.getEvents()).thenReturn(new ArrayList<>());
+    
when(batch.getEventType()).thenReturn(ReconEvent.EventType.OM_UPDATE_BATCH);
+    when(batch.getEventCount()).thenReturn(1);
+    return batch;
+  }
+
   @Test
   @org.junit.jupiter.api.Disabled("Task removal logic not implemented in async 
processing")
   public void testBadBehavedTaskIsIgnored() throws Exception {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to