浏览代码

ZOOKEEPER-511. bad error handling in FollowerHandle.sendPackets (mahadev via flavio)


git-svn-id: https://svn.apache.org/repos/asf/hadoop/zookeeper/trunk@921853 13f79535-47bb-0310-9956-ffa450edef68
Flavio Paiva Junqueira 15 年之前
父节点
当前提交
42e23d3a7d
共有 2 个文件被更改,包括 12 次插入1 次删除
  1. 3 0
      CHANGES.txt
  2. 9 1
      src/java/main/org/apache/zookeeper/server/quorum/LearnerHandler.java

+ 3 - 0
CHANGES.txt

@@ -267,6 +267,9 @@ BUGFIXES:
   ZOOKEEPER-696. NPE in the hudson logs, seems nioservercnxn closed twice 
   ZOOKEEPER-696. NPE in the hudson logs, seems nioservercnxn closed twice 
   (phunt via mahadev)
   (phunt via mahadev)
 
 
+  ZOOKEEPER-511. bad error handling in FollowerHandler.sendPackets
+  (mahadev via flavio)
+
 IMPROVEMENTS:
 IMPROVEMENTS:
   ZOOKEEPER-473. cleanup junit tests to eliminate false positives due to
   ZOOKEEPER-473. cleanup junit tests to eliminate false positives due to
   "socket reuse" and failure to close client (phunt via mahadev)
   "socket reuse" and failure to close client (phunt via mahadev)

+ 9 - 1
src/java/main/org/apache/zookeeper/server/quorum/LearnerHandler.java

@@ -139,7 +139,15 @@ public class LearnerHandler extends Thread {
                 oa.writeRecord(p, "packet");
                 oa.writeRecord(p, "packet");
             } catch (IOException e) {
             } catch (IOException e) {
                 if (!sock.isClosed()) {
                 if (!sock.isClosed()) {
-                    LOG.warn("Unexpected exception",e);
+                    LOG.warn("Unexpected exception at " + this, e);
+                    try {
+                        // this will cause everything to shutdown on
+                        // this learner handler and will help notify
+                        // the learner/observer instantaneously
+                        sock.close();
+                    } catch(IOException ie) {
+                        LOG.warn("Error closing socket for handler " + this, ie);
+                    }
                 }
                 }
                 break;
                 break;
             }
             }