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

smengcl 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 f5f9de8b60d HDDS-16262. Prevent AbstractCommitWatcher cleanup races 
(#11512)
f5f9de8b60d is described below

commit f5f9de8b60d4331de7d38dec0876639a8cdda2e8
Author: len548 <[email protected]>
AuthorDate: Sat Oct 17 14:48:46 2026 +0900

    HDDS-16262. Prevent AbstractCommitWatcher cleanup races (#11512)
---
 .../hdds/scm/storage/AbstractCommitWatcher.java    | 22 +++++++++++++++-------
 .../hadoop/hdds/scm/storage/CommitWatcher.java     |  2 +-
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git 
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/AbstractCommitWatcher.java
 
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/AbstractCommitWatcher.java
index 4dfc3c1c41b..8d078be9791 100644
--- 
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/AbstractCommitWatcher.java
+++ 
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/AbstractCommitWatcher.java
@@ -95,10 +95,14 @@ long addAckDataLength(long acked) {
    * @throws IOException in case watchForCommit fails
    */
   XceiverClientReply watchOnFirstIndex() throws IOException {
-    if (commitIndexMap.isEmpty()) {
-      return null;
+    long firstKey;
+    synchronized (this) {
+      if (commitIndexMap.isEmpty()) {
+        return null;
+      }
+      firstKey = commitIndexMap.firstKey();
     }
-    return watchForCommit(commitIndexMap.firstKey());
+    return watchForCommit(firstKey);
   }
 
   /**
@@ -111,10 +115,14 @@ XceiverClientReply watchOnFirstIndex() throws IOException 
{
    * @throws IOException in case watchForCommit fails
    */
   XceiverClientReply watchOnLastIndex() throws IOException {
-    if (commitIndexMap.isEmpty()) {
-      return null;
+    long lastKey;
+    synchronized (this) {
+      if (commitIndexMap.isEmpty()) {
+        return null;
+      }
+      lastKey = commitIndexMap.lastKey();
     }
-    return watchForCommit(commitIndexMap.lastKey());
+    return watchForCommit(lastKey);
   }
 
   /**
@@ -183,7 +191,7 @@ IOException getIOExceptionForWatchForCommit(long 
commitIndex, Exception e) {
     return ioException;
   }
 
-  void cleanup() {
+  synchronized void cleanup() {
     commitIndexMap.clear();
     replies.clear();
   }
diff --git 
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/CommitWatcher.java
 
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/CommitWatcher.java
index 9e85900a454..771d39b6494 100644
--- 
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/CommitWatcher.java
+++ 
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/CommitWatcher.java
@@ -54,7 +54,7 @@ void releaseBuffers(long index) {
   }
 
   @Override
-  public void cleanup() {
+  public synchronized void cleanup() {
     super.cleanup();
   }
 }


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

Reply via email to