Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-5572

KeeperException.SessionExpiredException management could be improved in Master

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.95.2
    • 0.95.0
    • master
    • None
    • Reviewed

    Description

      Synthesis:
      1) TestMasterZKSessionRecovery distinguish two cases on SessionExpiredException. One is explicitly not managed. However, is seems that there is no reason for this.
      2) The issue lies in ActiveMasterManager#blockUntilBecomingActiveMaster, a quite complex function, with a useless recursive call.
      3) TestMasterZKSessionRecovery#testMasterZKSessionRecoverySuccess is equivalent to TestZooKeeper#testMasterSessionExpired
      4) TestMasterZKSessionRecovery#testMasterZKSessionRecoveryFailure can be removed if we merge the two cases mentioned above.

      Changes are:
      2) Changing ActiveMasterManager#blockUntilBecomingActiveMaster to have a single case and remove recursion
      1) Removing TestMasterZKSessionRecovery

      Detailed justification:
      testMasterZKSessionRecoveryFailure says:

        /**
         * Negative test of master recovery from zk session expiry.
         *
         * Starts with one master. Fakes the master zk session expired.
         * Ensures the master cannot recover the expired zk session since
         * the master zk node is still there.
         */
        public void testMasterZKSessionRecoveryFailure() throws Exception {
          MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
          HMaster m = cluster.getMaster();
          m.abort("Test recovery from zk session expired",
            new KeeperException.SessionExpiredException());
          assertTrue(m.isStopped());
        }
      

      This tests works, i.e. the assertion is always verified.
      But do we really want this behavior?

      When looking at the code, we see that this what's happening is strange:

      • HMaster#abort calls Master#abortNow. If HMaster#abortNow returns false HMaster#abort stops the master.
      • HMaster#abortNow checks the exception type. As it's a SessionExpiredException it will try to recover, calling HMaster#tryRecoveringExpiredZKSession. If it cannot, it will return false (and that will make HMaster#abort stopping the master)
      • HMaster#tryRecoveringExpiredZKSession recreates a ZooKeeperConnection and then try to become the active master. If it cannot, it will return false (and that will make HMaster#abort stopping the master).
      • HMaster#becomeActiveMaster returns the result of ActiveMasterManager#blockUntilBecomingActiveMaster. blockUntilBecomingActiveMaster says it will return false if there is any error preventing it to become the active master.
      • ActiveMasterManager#blockUntilBecomingActiveMaster reads ZK for the master address. If it's the same port & host, it deletes the nodes, that will start a recursive call to blockUntilBecomingActiveMaster. This second call succeeds (we became the active master) and return true. This result is ignored by the first blockUntilBecomingActiveMaster: it return false (even if we actually became the active master), hence the whole suite call returns false and HMaster#abort stops the master.

      In other words, the comment says "Ensures the master cannot recover the expired zk session since the master zk node is still there." but we're actually doing a check just for this and deleting the node. If we were not ignoring the result, we would return "true", so we would not stop the master, so the test would fail.

      Attachments

        1. 5572.v2.patch
          13 kB
          Nicolas Liochon
        2. 5572.v2.patch
          13 kB
          Nicolas Liochon
        3. 5572.v2.patch
          13 kB
          Nicolas Liochon
        4. 5572.v1.patch
          12 kB
          Nicolas Liochon

        Issue Links

          Activity

            People

              nkeywal Nicolas Liochon
              nkeywal Nicolas Liochon
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: