zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iv...@apache.org
Subject svn commit: r1516938 - in /zookeeper/bookkeeper/branches/branch-4.2: CHANGES.txt bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestFencing.java
Date Fri, 23 Aug 2013 17:20:14 GMT
Author: ivank
Date: Fri Aug 23 17:20:13 2013
New Revision: 1516938

URL: http://svn.apache.org/r1516938
Log:
BOOKKEEPER-580: improve close logic (sijie & ivank via ivank)

Modified:
    zookeeper/bookkeeper/branches/branch-4.2/CHANGES.txt
    zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java
    zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestFencing.java

Modified: zookeeper/bookkeeper/branches/branch-4.2/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/branches/branch-4.2/CHANGES.txt?rev=1516938&r1=1516937&r2=1516938&view=diff
==============================================================================
--- zookeeper/bookkeeper/branches/branch-4.2/CHANGES.txt (original)
+++ zookeeper/bookkeeper/branches/branch-4.2/CHANGES.txt Fri Aug 23 17:20:13 2013
@@ -68,6 +68,8 @@ Release 4.2.2 - Unreleased
 
         BOOKKEEPER-649: Race condition in sync ZKUtils.createFullPathOptimistic() (ivank)
 
+        BOOKKEEPER-580: improve close logic (sijie & ivank via ivank)
+
       hedwig-server:
 
         BOOKKEEPER-579: TestSubAfterCloseSub was put in a wrong package (sijie via ivank)

Modified: zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java?rev=1516938&r1=1516937&r2=1516938&view=diff
==============================================================================
--- zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java
(original)
+++ zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java
Fri Aug 23 17:20:13 2013
@@ -252,6 +252,12 @@ public class LedgerHandle {
                 final State prevState;
 
                 synchronized(LedgerHandle.this) {
+                    // if the metadata is already closed, we don't need to proceed the process
+                    // otherwise, it might end up encountering bad version error log messages
when updating metadata
+                    if (metadata.isClosed()) {
+                        cb.closeComplete(BKException.Code.OK, LedgerHandle.this, ctx);
+                        return;
+                    }
                     prevState = metadata.getState();
                     prevLastEntryId = metadata.getLastEntryId();
                     prevLength = metadata.getLength();
@@ -261,8 +267,6 @@ public class LedgerHandle {
                     // is closed. 
                     metadata.setLength(length);
 
-                    // Close operation is idempotent, so no need to check if we are
-                    // already closed
                     metadata.close(lastAddConfirmed);
                     errorOutPendingAdds(rc);
                     lastAddPushed = lastAddConfirmed;

Modified: zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestFencing.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestFencing.java?rev=1516938&r1=1516937&r2=1516938&view=diff
==============================================================================
--- zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestFencing.java
(original)
+++ zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestFencing.java
Fri Aug 23 17:20:13 2013
@@ -292,12 +292,7 @@ public class TestFencing extends BaseTes
         }
 
         readlh.close();
-        try {
-            writelh.close();
-            fail("Should fail trying to update metadata");
-        } catch (BKException.BKMetadataVersionException e) {
-            // correct behaviour
-        }
+        writelh.close();
     }
 
     /**
@@ -338,13 +333,7 @@ public class TestFencing extends BaseTes
         }
 
         readlh.close();
-
-        try {
-            writelh.close();
-            fail("Should fail trying to update metadata");
-        } catch (BKException.BKMetadataVersionException e) {
-            // correct behaviour
-        }
+        writelh.close();
     }
 
     /**



Mime
View raw message