Details
-
Bug
-
Resolution: Won't Do
-
Major
-
None
-
1.4.2, 1.4.3
-
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) {
|
//
|
}
|
}
|
|
}
|
|