zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ph...@apache.org
Subject svn commit: r1757564 - in /zookeeper/trunk: CHANGES.txt src/c/src/zk_adaptor.h src/c/src/zookeeper.c src/c/tests/TestReconfig.cc
Date Wed, 24 Aug 2016 18:33:36 GMT
Author: phunt
Date: Wed Aug 24 18:33:36 2016
New Revision: 1757564

URL: http://svn.apache.org/viewvc?rev=1757564&view=rev
Log:
ZOOKEEPER-2152: Intermittent failure in TestReconfig.cc (Michael Han via phunt)

Modified:
    zookeeper/trunk/CHANGES.txt
    zookeeper/trunk/src/c/src/zk_adaptor.h
    zookeeper/trunk/src/c/src/zookeeper.c
    zookeeper/trunk/src/c/tests/TestReconfig.cc

Modified: zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/trunk/CHANGES.txt?rev=1757564&r1=1757563&r2=1757564&view=diff
==============================================================================
--- zookeeper/trunk/CHANGES.txt (original)
+++ zookeeper/trunk/CHANGES.txt Wed Aug 24 18:33:36 2016
@@ -356,6 +356,9 @@ BUGFIXES:
   with zk operation without connecting to ZooKeeper server.
   (Arshad Mohammad via phunt)
 
+  ZOOKEEPER-2152: Intermittent failure in TestReconfig.cc
+  (Michael Han via phunt)
+
 IMPROVEMENTS:
   ZOOKEEPER-2024 Major throughput improvement with mixed workloads (Kfir Lev-Ari via shralex)
 

Modified: zookeeper/trunk/src/c/src/zk_adaptor.h
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/c/src/zk_adaptor.h?rev=1757564&r1=1757563&r2=1757564&view=diff
==============================================================================
--- zookeeper/trunk/src/c/src/zk_adaptor.h (original)
+++ zookeeper/trunk/src/c/src/zk_adaptor.h Wed Aug 24 18:33:36 2016
@@ -202,6 +202,11 @@ struct _zhandle {
     int reconfig;                       // Are we in the process of reconfiguring cluster's
ensemble
     double pOld, pNew;                  // Probability for selecting between 'addrs_old'
and 'addrs_new'
     int delay;
+    int disable_reconnection_attempt;   // When set, client will not try reconnect to a different
server in
+                                        // server list. This makes a sticky server for client,
and is useful
+                                        // for testing if a sticky server is required, or
if client wants to
+                                        // explicitly shuffle server by calling zoo_cycle_next_server.
+                                        // The default value is 0.
 
     watcher_fn watcher;                 // the registered watcher
 

Modified: zookeeper/trunk/src/c/src/zookeeper.c
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/c/src/zookeeper.c?rev=1757564&r1=1757563&r2=1757564&view=diff
==============================================================================
--- zookeeper/trunk/src/c/src/zookeeper.c (original)
+++ zookeeper/trunk/src/c/src/zookeeper.c Wed Aug 24 18:33:36 2016
@@ -1177,6 +1177,7 @@ static zhandle_t *zookeeper_init_interna
     zh->active_node_watchers=create_zk_hashtable();
     zh->active_exist_watchers=create_zk_hashtable();
     zh->active_child_watchers=create_zk_hashtable();
+    zh->disable_reconnection_attempt = 0;
 
     if (adaptor_init(zh) == -1) {
         goto abort;
@@ -2194,8 +2195,10 @@ int zookeeper_interest(zhandle_t *zh, so
          *
          * We always clear the delay setting. If we fail again, we'll set delay
          * again and on the next iteration we'll do the same.
+         *
+         * We will also delay if the disable_reconnection_attempt is set.
          */
-        if (zh->delay == 1) {
+        if (zh->delay == 1 || zh->disable_reconnection_attempt == 1) {
             *tv = get_timeval(zh->recv_timeout/60);
             zh->delay = 0;
 

Modified: zookeeper/trunk/src/c/tests/TestReconfig.cc
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/c/tests/TestReconfig.cc?rev=1757564&r1=1757563&r2=1757564&view=diff
==============================================================================
--- zookeeper/trunk/src/c/tests/TestReconfig.cc (original)
+++ zookeeper/trunk/src/c/tests/TestReconfig.cc Wed Aug 24 18:33:36 2016
@@ -55,6 +55,11 @@ public:
         zh = zookeeper_init(hosts.c_str(),0,1000,0,0,0);
         CPPUNIT_ASSERT(zh);
 
+        // Set the flag to disable ZK from reconnecting to a different server.
+        // Our reconfig test case will do explicit server shuffling through
+        // zoo_cycle_next_server, and the reconnection attempts would interfere
+        // with the server states the tests cases assume.
+        zh->disable_reconnection_attempt = 1;
         reSeed();
 
         cycleNextServer();



Mime
View raw message