-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 3.0.1
-
Component/s: Async, Query Operations
-
None
We are using the mongoDB async java driver version 3.0.1. When doing performance tests (only reads) with a lot of concurrent requests to the driver, we sometimes encounter the following exception:
java.lang.IllegalStateException: Attempted to decrement the reference count below 0 at com.mongodb.binding.AbstractReferenceCounted.release(AbstractReferenceCounted.java:39) at com.mongodb.binding.AsyncClusterBinding$AsyncClusterBindingConnectionSource.release(AsyncClusterBinding.java:113) at com.mongodb.operation.AsyncQueryBatchCursor.killCursor(AsyncQueryBatchCursor.java:154) at com.mongodb.operation.AsyncQueryBatchCursor.close(AsyncQueryBatchCursor.java:79) at com.mongodb.operation.AsyncQueryBatchCursor.next(AsyncQueryBatchCursor.java:93) at com.mongodb.async.client.OperationIterable.loopCursor(OperationIterable.java:130) at com.mongodb.async.client.OperationIterable.access$000(OperationIterable.java:30) at com.mongodb.async.client.OperationIterable$4.onResult(OperationIterable.java:141) at com.mongodb.async.client.OperationIterable$4.onResult(OperationIterable.java:130) at com.mongodb.operation.AsyncQueryBatchCursor.next(AsyncQueryBatchCursor.java:90) at com.mongodb.async.client.OperationIterable.loopCursor(OperationIterable.java:130) at com.mongodb.async.client.OperationIterable.access$000(OperationIterable.java:30) at com.mongodb.async.client.OperationIterable$1.onResult(OperationIterable.java:51) at com.mongodb.async.client.OperationIterable$1.onResult(OperationIterable.java:45) at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53) at com.mongodb.async.client.MongoClientImpl$2$1.onResult(MongoClientImpl.java:129) at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53) at com.mongodb.operation.OperationHelper$ConnectionReleasingWrappedCallback.onResult(OperationHelper.java:140) at com.mongodb.operation.FindOperation$2$1.onResult(FindOperation.java:433) at com.mongodb.operation.FindOperation$2$1.onResult(FindOperation.java:427) at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53) at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor$1.onResult(DefaultServer.java:171) at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53) at com.mongodb.connection.QueryResultCallback.callCallback(QueryResultCallback.java:64) at com.mongodb.connection.ResponseCallback.onResult(ResponseCallback.java:48) at com.mongodb.connection.ResponseCallback.onResult(ResponseCallback.java:23) at com.mongodb.connection.DefaultConnectionPool$PooledConnection$2.onResult(DefaultConnectionPool.java:446) at com.mongodb.connection.DefaultConnectionPool$PooledConnection$2.onResult(DefaultConnectionPool.java:440) at com.mongodb.connection.UsageTrackingInternalConnection$3.onResult(UsageTrackingInternalConnection.java:127) at com.mongodb.connection.UsageTrackingInternalConnection$3.onResult(UsageTrackingInternalConnection.java:123) at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53) at com.mongodb.connection.InternalStreamConnection.executeCallbackAndReceiveResponse(InternalStreamConnection.java:375) at com.mongodb.connection.InternalStreamConnection.access$1700(InternalStreamConnection.java:65) at com.mongodb.connection.InternalStreamConnection$ResponseBuffersCallback.onResult(InternalStreamConnection.java:417) at com.mongodb.connection.InternalStreamConnection$ResponseBuffersCallback.onResult(InternalStreamConnection.java:386) at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback.onSuccess(InternalStreamConnection.java:555) at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback.access$2200(InternalStreamConnection.java:514) at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback$ResponseBodyCallback.onResult(InternalStreamConnection.java:577) at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback$ResponseBodyCallback.onResult(InternalStreamConnection.java:561) at com.mongodb.connection.InternalStreamConnection$3.completed(InternalStreamConnection.java:444) at com.mongodb.connection.InternalStreamConnection$3.completed(InternalStreamConnection.java:441) at com.mongodb.connection.AsynchronousSocketChannelStream$BasicCompletionHandler.completed(AsynchronousSocketChannelStream.java:217) at com.mongodb.connection.AsynchronousSocketChannelStream$BasicCompletionHandler.completed(AsynchronousSocketChannelStream.java:204) at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126) at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:281) at sun.nio.ch.WindowsAsynchronousSocketChannelImpl$ReadTask.completed(WindowsAsynchronousSocketChannelImpl.java:579) at sun.nio.ch.Iocp$EventHandlerTask.run(Iocp.java:397) at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
The IllegalStateException is passed into the callback when executing the following call chain:
searchCollection.find() .limit(10). .into(resultList, callback);