Details
-
Bug
-
Resolution: Duplicate
-
Major - P3
-
None
-
4.1.0
-
None
Description
Where the max connections is 100 the following code will fail to complete:
public static void main(final String[] args) {
|
MongoClient mongoClient = MongoClients.create("mongodb://localhost");
|
MongoDatabase db = mongoClient.getDatabase("import");
|
MongoCollection<Document> gameEntityCollection = db.getCollection("gameEnitites");
|
for (int i = 0; i < 200; i++) {
|
final int subscribeNumber = i;
|
System.out.println("Subscribe number " + subscribeNumber);
|
gameEntityCollection.watch().subscribe(new Subscriber<ChangeStreamDocument<Document>>() {
|
@Override
|
public void onSubscribe(Subscription s) {
|
s.request(1);
|
new Thread(() -> {
|
try {
|
Thread.sleep(1000);
|
s.cancel();
|
System.out.println("Cancelled Subscribe number " + subscribeNumber);
|
} catch (InterruptedException e) {
|
e.printStackTrace();
|
}
|
}).start();
|
}
|
|
|
@Override
|
public void onNext(ChangeStreamDocument<Document> t) {
|
}
|
|
|
@Override
|
public void onError(Throwable t) {
|
t.printStackTrace();
|
}
|
|
|
@Override
|
public void onComplete() {
|
System.out.println("Completed Subscribe number " + subscribeNumber);
|
}
|
});
|
CountDownLatch cd = new CountDownLatch(1);
|
gameEntityCollection.countDocuments().subscribe(new Subscriber<Long>() {
|
@Override
|
public void onSubscribe(Subscription s) {
|
s.request(Long.MAX_VALUE);
|
}
|
|
|
@Override
|
public void onNext(Long aLong) {
|
System.out.println("Subscribe number " + subscribeNumber + " collection size: " + aLong);
|
}
|
|
|
@Override
|
public void onError(Throwable t) {
|
}
|
|
|
@Override
|
public void onComplete() {
|
cd.countDown();
|
}
|
});
|
cd.await();
|
}
|
}
|
Attachments
Issue Links
- duplicates
-
JAVA-3907 AsyncQueryBatchCursor does not release ConnectionSource when closed
-
- Closed
-
- is duplicated by
-
JAVA-3907 AsyncQueryBatchCursor does not release ConnectionSource when closed
-
- Closed
-
- is related to
-
JAVA-3487 com.mongodb.MongoException: state should be: open when closing an change stream
-
- Closed
-