ZooKeeper
  1. ZooKeeper
  2. ZOOKEEPER-1871

Add an option to zkCli to wait for connection before executing commands

    Details

    • Type: Improvement Improvement
    • Status: Patch Available
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 3.4.5
    • Fix Version/s: 3.5.2, 3.6.0
    • Component/s: None
    • Labels:
      None
    • Release Note:
      Hide
      Change zkCli.sh so as to wait until connection to quorum is done.
      Add an option -waitforconnection for cmd args option to set this timeout to be same with session timeout.
      Show
      Change zkCli.sh so as to wait until connection to quorum is done. Add an option -waitforconnection for cmd args option to set this timeout to be same with session timeout.

      Description

      Add an option to zkCli to wait for connection before executing any commands.
      This is helpful for the execution of inline commands.

      We are having some scripts to create/delete znodes through commandline. But if getting the connection delays due to one of the node down, then command will fail with connectionloss even though quorum is available.

      So I propose a commandline option (similar to -server and -timeout) "-waitforconnection" to wait for the connection before executing any commands.

      1. ZOOKEEPER-1871.patch
        4 kB
        Takashi Ohnishi
      2. ZOOKEEPER-1871.patch
        5 kB
        Takashi Ohnishi
      3. ZOOKEEPER-1871.patch
        6 kB
        Takashi Ohnishi
      4. ZOOKEEPER-1871.patch
        6 kB
        Takashi Ohnishi

        Activity

        Hide
        Takashi Ohnishi added a comment -

        Hi.

        > We are having some scripts to create/delete znodes through commandline. But if getting the connection delays due to one of the node down,
        > then command will fail with connectionloss even though quorum is available.

        We encountered the same situation. So, I want the proposed option, too!

        I have attached a created patch for version 3.4.5.
        This patch adds a option -waitforconnection to zkCli.sh and changes the usage of zkCli.sh as below.

           $ bin/zkCli.sh -server host:port -timeout sessionTimeout[ms] -waitforconnection waittimeout[ms] cmd args
        

        zkCli.sh comes to wait for completion of connecting to a ZooKeeper server with the specified milliseconds timeout.
        Without the -waitforconnection option, zkCli.sh use a default value 30,000 millisecond.

        Show
        Takashi Ohnishi added a comment - Hi. > We are having some scripts to create/delete znodes through commandline. But if getting the connection delays due to one of the node down, > then command will fail with connectionloss even though quorum is available. We encountered the same situation. So, I want the proposed option, too! I have attached a created patch for version 3.4.5. This patch adds a option -waitforconnection to zkCli.sh and changes the usage of zkCli.sh as below. $ bin/zkCli.sh -server host:port -timeout sessionTimeout[ms] -waitforconnection waittimeout[ms] cmd args zkCli.sh comes to wait for completion of connecting to a ZooKeeper server with the specified milliseconds timeout. Without the -waitforconnection option, zkCli.sh use a default value 30,000 millisecond.
        Hide
        Rakesh R added a comment -

        Hi Takashi Ohnishi, Thanks for the patch. Few comments, please see

        • Does it really required to introduce a new argument "-waitforconnection" for the connection stablishment.
          Instead can we think of reusing the "-timeout" option value and can wait till the session timeout for the connection establishment. I hope deafult value 30seconds is large time, isn't it?
        • In tests, please add message part, it will give some hint for others about the expectation.
          Assert.assertTrue(end_time - start_time > wait_timeout); 
          

        After attaching the patch, please do 'Submit Patch', this will trigger the regression and gets the QA report.

        Show
        Rakesh R added a comment - Hi Takashi Ohnishi , Thanks for the patch. Few comments, please see Does it really required to introduce a new argument "-waitforconnection" for the connection stablishment. Instead can we think of reusing the "-timeout" option value and can wait till the session timeout for the connection establishment. I hope deafult value 30seconds is large time, isn't it? In tests, please add message part, it will give some hint for others about the expectation. Assert.assertTrue(end_time - start_time > wait_timeout); After attaching the patch, please do 'Submit Patch', this will trigger the regression and gets the QA report.
        Hide
        Takashi Ohnishi added a comment -

        Hi Rakesh. Thank you for review and comments!

        >Does it really required to introduce a new argument "-waitforconnection" for the connection stablishment.
        >Instead can we think of reusing the "-timeout" option value and can wait till the session timeout for the connection establishment. I hope deafult value >30seconds is large time, isn't it?

        All right.
        I will change default value of this new timeout to 5 seconds. I think that it is enough to complete connection to quorum, even if one server is down.

        And I will also change the behavior of this option:
        (a) if -waitforconnection option is specified, zkCli.sh wait with same value as session timeout until connection to quorum is done
        (b) if -waitforconnection options is not specified, zkCli.sh wait with default 5 seconds until connection to quorum is done
        So, the usage is as below:

          $ bin/zkCli.sh [-server host:port] [-timeout sessionTimeout[ms]] [-waitforconnection] cmd args 
        

        How about?

        >In tests, please add message part, it will give some hint for others about the expectation.

        I will fix it.

        >After attaching the patch, please do 'Submit Patch', this will trigger the regression and gets the QA report.

        I will do so. Thanks!

        Show
        Takashi Ohnishi added a comment - Hi Rakesh. Thank you for review and comments! >Does it really required to introduce a new argument "-waitforconnection" for the connection stablishment. >Instead can we think of reusing the "-timeout" option value and can wait till the session timeout for the connection establishment. I hope deafult value >30seconds is large time, isn't it? All right. I will change default value of this new timeout to 5 seconds. I think that it is enough to complete connection to quorum, even if one server is down. And I will also change the behavior of this option: (a) if -waitforconnection option is specified, zkCli.sh wait with same value as session timeout until connection to quorum is done (b) if -waitforconnection options is not specified, zkCli.sh wait with default 5 seconds until connection to quorum is done So, the usage is as below: $ bin/zkCli.sh [-server host:port] [-timeout sessionTimeout[ms]] [-waitforconnection] cmd args How about? >In tests, please add message part, it will give some hint for others about the expectation. I will fix it. >After attaching the patch, please do 'Submit Patch', this will trigger the regression and gets the QA report. I will do so. Thanks!
        Hide
        Rakesh R added a comment -

        And I will also change the behavior of this option:
        (a) if -waitforconnection option is specified, zkCli.sh wait with same value as session timeout until connection to quorum is done
        (b) if -waitforconnection options is not specified, zkCli.sh wait with default 5 seconds until connection to quorum is done

        +1 for this approach

        Show
        Rakesh R added a comment - And I will also change the behavior of this option: (a) if -waitforconnection option is specified, zkCli.sh wait with same value as session timeout until connection to quorum is done (b) if -waitforconnection options is not specified, zkCli.sh wait with default 5 seconds until connection to quorum is done +1 for this approach
        Hide
        Takashi Ohnishi added a comment -

        updated after Rakesh comments

        Show
        Takashi Ohnishi added a comment - updated after Rakesh comments
        Hide
        Takashi Ohnishi added a comment -

        Hi.

        I updated my patch as discussion as above.
        In addition, I also added some notation in documentation.

        Thanks.

        Show
        Takashi Ohnishi added a comment - Hi. I updated my patch as discussion as above. In addition, I also added some notation in documentation. Thanks.
        Hide
        Hadoop QA added a comment -

        -1 overall. Here are the results of testing the latest attachment
        http://issues.apache.org/jira/secure/attachment/12631137/ZOOKEEPER-1871.patch
        against trunk revision 1569590.

        +1 @author. The patch does not contain any @author tags.

        +1 tests included. The patch appears to include 3 new or modified tests.

        -1 patch. The patch command could not apply the patch.

        Console output: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1933//console

        This message is automatically generated.

        Show
        Hadoop QA added a comment - -1 overall. Here are the results of testing the latest attachment http://issues.apache.org/jira/secure/attachment/12631137/ZOOKEEPER-1871.patch against trunk revision 1569590. +1 @author. The patch does not contain any @author tags. +1 tests included. The patch appears to include 3 new or modified tests. -1 patch. The patch command could not apply the patch. Console output: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1933//console This message is automatically generated.
        Hide
        Takashi Ohnishi added a comment -

        Sorry.

        The submitted patch was for version 3.4.5.
        I will create a patch for trunk and submit.

        Show
        Takashi Ohnishi added a comment - Sorry. The submitted patch was for version 3.4.5. I will create a patch for trunk and submit.
        Hide
        Hadoop QA added a comment -

        -1 overall. Here are the results of testing the latest attachment
        http://issues.apache.org/jira/secure/attachment/12631181/ZOOKEEPER-1871.patch
        against trunk revision 1569590.

        +1 @author. The patch does not contain any @author tags.

        +1 tests included. The patch appears to include 3 new or modified tests.

        +1 javadoc. The javadoc tool did not generate any warning messages.

        +1 javac. The applied patch does not increase the total number of javac compiler warnings.

        -1 findbugs. The patch appears to introduce 1 new Findbugs (version 1.3.9) warnings.

        +1 release audit. The applied patch does not increase the total number of release audit warnings.

        +1 core tests. The patch passed core unit tests.

        +1 contrib tests. The patch passed contrib unit tests.

        Test results: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1934//testReport/
        Findbugs warnings: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1934//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
        Console output: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1934//console

        This message is automatically generated.

        Show
        Hadoop QA added a comment - -1 overall. Here are the results of testing the latest attachment http://issues.apache.org/jira/secure/attachment/12631181/ZOOKEEPER-1871.patch against trunk revision 1569590. +1 @author. The patch does not contain any @author tags. +1 tests included. The patch appears to include 3 new or modified tests. +1 javadoc. The javadoc tool did not generate any warning messages. +1 javac. The applied patch does not increase the total number of javac compiler warnings. -1 findbugs. The patch appears to introduce 1 new Findbugs (version 1.3.9) warnings. +1 release audit. The applied patch does not increase the total number of release audit warnings. +1 core tests. The patch passed core unit tests. +1 contrib tests. The patch passed contrib unit tests. Test results: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1934//testReport/ Findbugs warnings: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1934//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html Console output: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1934//console This message is automatically generated.
        Hide
        Takashi Ohnishi added a comment -

        modify to eliminate findbugs warnings.

        Show
        Takashi Ohnishi added a comment - modify to eliminate findbugs warnings.
        Hide
        Hadoop QA added a comment -

        -1 overall. Here are the results of testing the latest attachment
        http://issues.apache.org/jira/secure/attachment/12631213/ZOOKEEPER-1871.patch
        against trunk revision 1569590.

        +1 @author. The patch does not contain any @author tags.

        +1 tests included. The patch appears to include 3 new or modified tests.

        +1 javadoc. The javadoc tool did not generate any warning messages.

        +1 javac. The applied patch does not increase the total number of javac compiler warnings.

        +1 findbugs. The patch does not introduce any new Findbugs (version 1.3.9) warnings.

        +1 release audit. The applied patch does not increase the total number of release audit warnings.

        -1 core tests. The patch failed core unit tests.

        +1 contrib tests. The patch passed contrib unit tests.

        Test results: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1935//testReport/
        Findbugs warnings: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1935//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
        Console output: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1935//console

        This message is automatically generated.

        Show
        Hadoop QA added a comment - -1 overall. Here are the results of testing the latest attachment http://issues.apache.org/jira/secure/attachment/12631213/ZOOKEEPER-1871.patch against trunk revision 1569590. +1 @author. The patch does not contain any @author tags. +1 tests included. The patch appears to include 3 new or modified tests. +1 javadoc. The javadoc tool did not generate any warning messages. +1 javac. The applied patch does not increase the total number of javac compiler warnings. +1 findbugs. The patch does not introduce any new Findbugs (version 1.3.9) warnings. +1 release audit. The applied patch does not increase the total number of release audit warnings. -1 core tests. The patch failed core unit tests. +1 contrib tests. The patch passed contrib unit tests. Test results: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1935//testReport/ Findbugs warnings: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1935//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html Console output: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1935//console This message is automatically generated.
        Hide
        Takashi Ohnishi added a comment -

        Hmm. 1core test was failed.

        But, former patch succeeded it and I made a slight change of discarding unused local variable...

        Looking the error messages, this fail seems to be related ZOOKEEPER-1870, maybe.

        {core}
        junit.framework.AssertionFailedError: client could not connect to reestablished quorum: giving up after 30+ seconds.
        at org.apache.zookeeper.test.ReconfigTest.testNormalOperation(ReconfigTest.java:153)
        at org.apache.zookeeper.server.quorum.StandaloneDisabledTest.startSingleServerTest(StandaloneDisabledTest.java:75)
        at org.apache.zookeeper.JUnit4ZKTestRunner$LoggedInvokeMethod.evaluate(JUnit4ZKTestRunner.java:52){core}
        Show
        Takashi Ohnishi added a comment - Hmm. 1core test was failed. But, former patch succeeded it and I made a slight change of discarding unused local variable... Looking the error messages, this fail seems to be related ZOOKEEPER-1870 , maybe. {core} junit.framework.AssertionFailedError: client could not connect to reestablished quorum: giving up after 30+ seconds. at org.apache.zookeeper.test.ReconfigTest.testNormalOperation(ReconfigTest.java:153) at org.apache.zookeeper.server.quorum.StandaloneDisabledTest.startSingleServerTest(StandaloneDisabledTest.java:75) at org.apache.zookeeper.JUnit4ZKTestRunner$LoggedInvokeMethod.evaluate(JUnit4ZKTestRunner.java:52){core}
        Hide
        Hadoop QA added a comment -

        -1 overall. Here are the results of testing the latest attachment
        http://issues.apache.org/jira/secure/attachment/12631213/ZOOKEEPER-1871.patch
        against trunk revision 1628086.

        +1 @author. The patch does not contain any @author tags.

        +1 tests included. The patch appears to include 3 new or modified tests.

        -1 patch. The patch command could not apply the patch.

        Console output: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/2353//console

        This message is automatically generated.

        Show
        Hadoop QA added a comment - -1 overall. Here are the results of testing the latest attachment http://issues.apache.org/jira/secure/attachment/12631213/ZOOKEEPER-1871.patch against trunk revision 1628086. +1 @author. The patch does not contain any @author tags. +1 tests included. The patch appears to include 3 new or modified tests. -1 patch. The patch command could not apply the patch. Console output: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/2353//console This message is automatically generated.
        Hide
        Hadoop QA added a comment -

        -1 overall. Here are the results of testing the latest attachment
        http://issues.apache.org/jira/secure/attachment/12631213/ZOOKEEPER-1871.patch
        against trunk revision 1672934.

        +1 @author. The patch does not contain any @author tags.

        +1 tests included. The patch appears to include 3 new or modified tests.

        -1 patch. The patch command could not apply the patch.

        Console output: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/2631//console

        This message is automatically generated.

        Show
        Hadoop QA added a comment - -1 overall. Here are the results of testing the latest attachment http://issues.apache.org/jira/secure/attachment/12631213/ZOOKEEPER-1871.patch against trunk revision 1672934. +1 @author. The patch does not contain any @author tags. +1 tests included. The patch appears to include 3 new or modified tests. -1 patch. The patch command could not apply the patch. Console output: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/2631//console This message is automatically generated.

          People

          • Assignee:
            Takashi Ohnishi
            Reporter:
            Vinayakumar B
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:

              Development