Uploaded image for project: 'Couchbase Java Client'
  1. Couchbase Java Client
  2. JCBC-773

The v2 of the java client leaks RxJava threads on shutdown

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 2.1.4, 2.2.0-dp2, 2.2.1, 2.1.5
    • 2.1.3
    • None
    • Security Level: Public
    • None

    Description

      ( Issue initially reported here : https://forums.couchbase.com/t/the-v2-of-the-java-client-leaks-rxjava-threads-on-shutdown/3890 )

      We use the couchbase client v2.1.3 in a webapp application : in development we use hot redeployment and we got memory issues probably caused by the fact that RxJava Threads are not stopped when we close the couchbase client :
      After few redeployments several duplicated RxJava Threads are present and a memory dump shows that they hold the old classloaders.

      The issue is easy to reproduce in a simple main class :
      Just create de couchbase client Cluster, connect to a Bucket and do a little query then stop the Cluster (Cluster.shutdown).
      Then if you dump the threads and you see there are still some RxJava Threads :

      In my case before Cluster shutdown, I have these threads :

      • 13 : cb-io-1-4
      • 25 : threadDeathWatcher-4-1
      • 12 : cb-io-1-3
      • 11 : cb-io-1-2
      • 10 : cb-io-1-1
      • 23 : cb-computations-4
      • 22 : cb-computations-3
      • 21 : cb-computations-2
      • 20 : cb-computations-1
      • 19 : cb-core-3-2
      • 18 : cb-core-3-1
      • 16 : RxComputationThreadPool-3
      • 15 : RxComputationThreadPool-2
      • 14 : RxComputationThreadPool-1
        (jvm threads ommitted)

      And after the shutdown, there is still the following threads :

      • 25 : threadDeathWatcher-4-1
      • 23 : cb-computations-4
      • 22 : cb-computations-3
      • 21 : cb-computations-2
      • 20 : cb-computations-1
      • 16 : RxComputationThreadPool-3
      • 15 : RxComputationThreadPool-2
      • 14 : RxComputationThreadPool-1
        (jvm threads ommitted)

      (dumping threads with :
      ThreadInfo[] threadInfos = threadMXBean.getThreadInfo(threadMXBean.getAllThreadIds());
      for(ThreadInfo ti : threadInfos)

      { System.out.printf(" - %s : %s%n",ti.getThreadId(), ti.getThreadName()); }

      )

      Attachments

        Issue Links

          For Gerrit Dashboard: JCBC-773
          # Subject Branch Project Status CR V

          Activity

            People

              simonbasle Simon Baslé (Inactive)
              farrault farrault
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty