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

Couchbase hangs during tomcat shutdown

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Major
    • None
    • 1.4.2, 1.4.3
    • Core
    • Security Level: Public
    • None
    • Tomcat 7.0.45.

    Description

      Using couchbase lib inside a WAR. All clients connections are stopped by the application but Tomcat can't stop.
      Tomcat stop process is blocked by a CouchbaseConfigConnection thread (deamon=false)

        java.lang.Thread.State: RUNNABLE
          at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
          at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:269)
          at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:79)
          at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:87)
          - locked <0x0000000795b80af0> (a sun.nio.ch.Util$2)
          - locked <0x0000000795b80b00> (a java.util.Collections$UnmodifiableSet)
          - locked <0x0000000795b80aa8> (a sun.nio.ch.EPollSelectorImpl)
          at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:98)
          at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:420)
          at com.couchbase.client.CouchbaseConnection.run(CouchbaseConnection.java:321)
      

      Looking a the bootstrap code from com.couchbase.client.vbucket.provider.BucketConfigurationProvider class.
      A CouchbaseConfigConnection is created but not closed if everything is working fine.

      private boolean tryBinaryBootstrapForNode(InetSocketAddress node)
          throws Exception 
       
        connection = new CouchbaseConfigConnection(
              cf.getReadBufSize(), fact, Collections.singletonList(node),
              initialObservers, cf.getFailureMode(),
              cf.getOperationFactory()
            );
      
      

      Hack to resolve the issue.

        private void killConfigConnection(){
              ThreadGroup rootGroup = Thread.currentThread( ).getThreadGroup( );
              ThreadGroup parentGroup;
              while ( ( parentGroup = rootGroup.getParent() ) != null ) {
                  rootGroup = parentGroup;
              }
       
              Thread[] threads = new Thread[ rootGroup.activeCount() ];
              while ( rootGroup.enumerate( threads, true ) == threads.length ) {
                  threads = new Thread[ threads.length * 2 ];
              }
       
              for (int i = 0; i < threads.length; i++){
                  final Thread thread = threads[i];
                  if(thread instanceof CouchbaseConfigConnection){
                      final CouchbaseConfigConnection configConn = (CouchbaseConfigConnection) thread;
                      try {
                          configConn.shutdown();
                      } catch (final IOException e) {
                         //
                      }
                  }
       
              }
         
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            daschl Michael Nitschinger
            devantor Benoit Beaudet
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty