Uploaded image for project: 'Kylin'
  1. Kylin
  2. KYLIN-2862

BasicClientConnManager in RestClient can't do well with syncing many query severs

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • v2.1.0
    • v2.2.0
    • Others
    • None

    Description

      In KYLIN-2814 , it fixs some kinds of sync wipe fails.
      After we use this patch , sync wipe fails still often happen, the log is like this.

      2017-09-08 21:28:13,029 WARN [pool-10-thread-2] cachesync.Broadcaster:137 : Thread failed during wipe cache at BroadcastEvent

      {entity=cube, event=update, cacheKey=olap_nh_log_all_di_cube}

      , error msg: java.lang.IllegalStateException: Invalid use of BasicClientConnManager: connection still allocated.
      Make sure to release the connection before allocating another one.

      We search the code, then we found , the DefaultHttpClient uses BasicClientConnManager as default ConnManager.
      and the BasicClientConnManager is a simple connection manager that maintains only one connection at a time. Even though this class is thread-safe it ought to be used by one execution thread only.

      if we have many query servers, the BasicClientConnManager will be bottleneck.
      so we use PoolingClientConnectionManager instead, which can manages a pool of client connections and is able to service connection requests from multiple execution threads.

      Then everything goes fine. the code is below

      final PoolingClientConnectionManager cm = new PoolingClientConnectionManager();
      cm.setDefaultMaxPerRoute(20);
      cm.setMaxTotal(200);
      client = new DefaultHttpClient(cm, httpParams);

      see more about BasicClientConnManager and PoolingClientConnectionManager
      http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html#d5e619

      Attachments

        1. KYLIN-2862.1.patch
          4 kB
          Fangyuan Deng
        2. KYLIN-2862.0.patch
          2 kB
          Fangyuan Deng

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            whisper_deng Fangyuan Deng
            whisper_deng Fangyuan Deng
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment