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 ac9c67f20a6 HDDS-17043. Recon emits a second DELETE event with a stale 
value when a key is deleted twice within one delta sync, and subtracts the key 
twice (#12006)
ac9c67f20a6 is described below

commit ac9c67f20a61109261620295480505c72f57ca78
Author: Arafat2198 <[email protected]>
AuthorDate: Wed Nov 18 11:29:46 2026 +0530

    HDDS-17043. Recon emits a second DELETE event with a stale value when a key 
is deleted twice within one delta sync, and subtracts the key twice (#12006)
    
    Co-authored-by: Claude <[email protected]>
---
 .../apache/hadoop/ozone/recon/tasks/OMDBUpdatesHandler.java   |  6 ++++++
 .../hadoop/ozone/recon/tasks/TestOMDBUpdatesHandler.java      | 11 +++--------
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/OMDBUpdatesHandler.java
 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/OMDBUpdatesHandler.java
index 3ae38428a66..854ccc1202d 100644
--- 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/OMDBUpdatesHandler.java
+++ 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/OMDBUpdatesHandler.java
@@ -171,6 +171,12 @@ private void processEvent(int cfIndex, byte[] keyBytes, 
byte[]
           }
         }
       } else if (action.equals(DELETE)) {
+        if (latestEvent != null && latestEvent.getAction() == DELETE) {
+          // The key was already deleted earlier in this delta, so there is 
nothing left to delete. This happens
+          // when OM re-creates and deletes the key in one flush: its batch 
keeps only the last write, the DELETE.
+          // Emitting it would reuse the stale row of the earlier DELETE and 
make the tasks subtract the key twice.
+          return;
+        }
         if (null == oldValue) {
           String keyStr = (key instanceof String) ? key.toString() : "";
           if (keyStr.isEmpty()) {
diff --git 
a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestOMDBUpdatesHandler.java
 
b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestOMDBUpdatesHandler.java
index 7ec3a6f3088..d0646cdf2e3 100644
--- 
a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestOMDBUpdatesHandler.java
+++ 
b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestOMDBUpdatesHandler.java
@@ -242,7 +242,8 @@ public void testOperateOnSameEntry() throws Exception {
     OMDBUpdatesHandler omdbUpdatesHandler = captureEvents(writeBatches);
 
     List<OMDBUpdateEvent> events = omdbUpdatesHandler.getEvents();
-    assertEquals(7, events.size());
+    // The second delete finds the key already deleted, so it yields no event.
+    assertEquals(6, events.size());
 
     OMDBUpdateEvent volEvent = events.get(0);
     assertEquals(PUT, volEvent.getAction());
@@ -281,13 +282,7 @@ public void testOperateOnSameEntry() throws Exception {
     assertEquals("key_new2",
         ((OmKeyInfo)keyDeleteEvent.getValue()).getKeyName());
 
-    OMDBUpdateEvent keyDeleteEvent2 = events.get(5);
-    assertEquals(DELETE, keyDeleteEvent2.getAction());
-    assertEquals("/sampleVol/bucketOne/key", keyDeleteEvent2.getKey());
-    assertEquals("key_new2",
-        ((OmKeyInfo)keyDeleteEvent2.getValue()).getKeyName());
-
-    OMDBUpdateEvent keyPut2 = events.get(6);
+    OMDBUpdateEvent keyPut2 = events.get(5);
     assertEquals(PUT, keyPut2.getAction());
     assertEquals("/sampleVol/bucketOne/key", keyPut2.getKey());
     assertEquals("key_new2",


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

Reply via email to