-
Type: Bug
-
Resolution: Gone away
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
If we analyze the code:
private void getMore() { Connection connection = connectionSource.getConnection(); try { if (serverIsAtLeastVersionThreeDotTwo(connection.getDescription())) { try { initFromCommandResult(connection.command(namespace.getDatabaseName(), asGetMoreCommandDocument(), NO_OP_FIELD_NAME_VALIDATOR, ReadPreference.primary(), CommandResultDocumentCodec.create(decoder, "nextBatch"), connectionSource.getSessionContext())); } catch (MongoCommandException e) { throw translateCommandException(e, serverCursor); } } else { QueryResult<T> getMore = connection.getMore(namespace, serverCursor.getId(), getNumberToReturn(limit, batchSize, count), decoder); initFromQueryResult(getMore); } if (limitReached()) { killCursor(connection); } if (serverCursor == null) { this.connectionSource.release(); this.connectionSource = null; } } finally { connection.release(); } }
The killCursor function is not inside a try..catch/finally so the connection is being closed in case of an exception but the cursor is not.
In certain situations, the application can start pilling up cursors on mongos leading to OOM.
- is related to
-
JAVA-3774 Ensure connectionSource is released if killCursors fails in the QueryBatchCursor
- Closed