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

Zookeeper sync() call is async

    XMLWordPrintableJSON

Details

    • Hide
      <!-- markdown -->

      Fixes a couple of bugs in ZooKeeper interaction. Firstly, zk sync() call that is used to sync the lagging followers with leader so that the client sees a consistent snapshot state was actually asynchronous under the hood. We make it synchronous for correctness. Second, zookeeper events are now processed in a separate thread rather than doing it in the thread context of zookeeper client connection. This decoupling frees up client connection quickly and avoids deadlocks.
      Show
      <!-- markdown --> Fixes a couple of bugs in ZooKeeper interaction. Firstly, zk sync() call that is used to sync the lagging followers with leader so that the client sees a consistent snapshot state was actually asynchronous under the hood. We make it synchronous for correctness. Second, zookeeper events are now processed in a separate thread rather than doing it in the thread context of zookeeper client connection. This decoupling frees up client connection quickly and avoids deadlocks.

    Description

      Here is the method that does a sync() of lagging followers with leader in the quorum. We rely on this to see a consistent snapshot of ZK data from multiple clients. However the problem is that the underlying sync() call is actually asynchronous since we are passing a 'null' call back. See the ZK API doc for details. The end-result is that sync() doesn't guarantee that it has happened by the time it returns.

        /**
         * Forces a synchronization of this ZooKeeper client connection.
         * <p>
         * Executing this method before running other methods will ensure that the
         * subsequent operations are up-to-date and consistent as of the time that
         * the sync is complete.
         * <p>
         * This is used for compareAndSwap type operations where we need to read the
         * data of an existing node and delete or transition that node, utilizing the
         * previously read version and data.  We want to ensure that the version read
         * is up-to-date from when we begin the operation.
         */
        public void sync(String path) throws KeeperException {
          this.recoverableZooKeeper.sync(path, null, null);
        }
      

      We rely on this heavily (at least in the older branches that do ZK based region assignment). In branch-1 we saw weird "BadVersionException" exceptions in RITs because of the inconsistent view of the ZK snapshot. It could manifest differently in other branches. Either way, this is something we need to fix.

      Attachments

        Issue Links

          Activity

            People

              bharathv Bharath Vissapragada
              bharathv Bharath Vissapragada
              Votes:
              0 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: