[JAVA-2603] Fix racy test in ChangeStreamOperationSpecification Created: 18/Sep/17  Updated: 29/Oct/23  Resolved: 01/Dec/17

Status: Closed
Project: Java Driver
Component/s: Test Coverage
Affects Version/s: None
Fix Version/s: 3.6.0

Type: Improvement Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The test "should support return the expected results" in ChangeStreamOperationSpecification is racy. Because closing an asynchronous cursor is itself asynchronous, in some cases the cleanup checks in ServerHelper#checkPool can run before the close completes, resulting in the following failure:

java.lang.IllegalStateException: Connection pool in use count is 1
	at com.mongodb.connection.ServerHelper.checkPool(ServerHelper.java:60)
	at com.mongodb.connection.ServerHelper.checkPool(ServerHelper.java:34)
	at com.mongodb.OperationFunctionalSpecification.cleanup(OperationFunctionalSpecification.groovy:69)

So far, I haven't seen this in the debugger or on evergreen, but I can reproduce it with a local replica set with this command line:

./gradlew -Dorg.mongodb.test.uri=mongodb://jeff:27017,jeff:27018/?replicaset=replset driver-core:test



 Comments   
Comment by Githook User [ 04/Dec/17 ]

Author:

{'username': 'jyemin', 'email': 'jeff.yemin@10gen.com', 'name': 'Jeff Yemin'}

Message: JAVA-2603: Wait for all connections pools to have no checked out connections after closing an asynchronous cursor.

Avoid a race condition between the async cursor closing and the check for checked out connections in the common cleanup method
Branch: 3.6.x
https://github.com/mongodb/mongo-java-driver/commit/17a80a2fd106facad05500290c0c9a175173ba55

Comment by Githook User [ 01/Dec/17 ]

Author:

{'name': 'Jeff Yemin', 'username': 'jyemin', 'email': 'jeff.yemin@10gen.com'}

Message: JAVA-2603: Wait for all connections pools to have no checked out connections after closing an asynchronous cursor.

Avoid a race condition between the async cursor closing and the check for checked out connections in the common cleanup method
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/17a80a2fd106facad05500290c0c9a175173ba55

Comment by Jeffrey Yemin [ 27/Nov/17 ]

Fixed in: https://github.com/mongodb/mongo-java-driver/commit/8e62c8aa42e383ef42be11ee15dc59167af14dc0

Comment by Jeffrey Yemin [ 18/Oct/17 ]

A similar change stream-related failure showed up in Evergreen here

Generated at Thu Feb 08 08:57:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.