Uploaded image for project: 'ZooKeeper'
  1. ZooKeeper
  2. ZOOKEEPER-4565

Config watch path get truncated abnormally and fail chroot zookeeper client

    XMLWordPrintableJSON

Details

    Description

      ClientCnxn strips off chrootPath for notifications. This strip could break "/zookeeper/config" to illegal zookeeper path(aka. not start with "/") and fail zookeeper client due to index out of bound exception in PathParentIterator.next.

                      // convert from a server path to a client path
                      if (chrootPath != null) {
                          String serverPath = event.getPath();
                          if (serverPath.compareTo(chrootPath) == 0) {
                              event.setPath("/");
                          } else if (serverPath.length() > chrootPath.length()) {
                              event.setPath(serverPath.substring(chrootPath.length()));
                           } else {
                               LOG.warn("Got server path {} which is too short for chroot path {}.",
                                   event.getPath(), chrootPath);
                           }
                      }
      

      I think we could make this strip similar to c client version sub_string and warns only for not "/zookeeper" nodes.

      I found this issue in reproducing CURATOR-593 and CURATOR-611. And the consequences are different in 3.6.3 and before.

      • Before 3.6.3(exclusive), watcher of getConfig will receive event with illegal path.
      • After 3.6.3(inclusive), the client will disconnect due to exception from ZKWatchManager.addPersistentWatches which calls PathParentIterator.forAll. See codes from 3.6.3 and 3.7+.

      Attachments

        Issue Links

          Activity

            People

              kezhuw Kezhu Wang
              kezhuw Kezhu Wang
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 2h
                  2h