[JAVA-1202] Driver should dedicate a thread to monitor each server Created: 04/May/14  Updated: 31/Mar/15  Resolved: 14/May/14

Status: Closed
Project: Java Driver
Component/s: Cluster Management
Affects Version/s: 2.12.0, 2.12.1
Fix Version/s: 2.12.2, 3.0.0

Type: Bug Priority: Critical - P2
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related

 Description   

In 2.12.0, the driver started using a ScheduledExecutorService to monitor the servers in MongoClient. This service was initialized to use a number of threads equal to the size of the seed list given to MongoClient. The idea was to reduce resource consumption by minimizing the number of background threads created by MongoClient, though this number could be increased using com.mongodb.MongoClientOptions.Builder#heartbeatThreadCount.

However, under some circumstances where servers are unavailable and take a significant amount of time to timeout on connect, this could result in starvation, and prevent the MongoClient from having enough free threads to monitor servers that are actually reachable and available.

To fix this, we are going to change the design so that the client dedicates a single-threaded ScheduledExecutorService for each server being monitored. This will eliminate the possibility of starvation, at the expense of slightly higher resource consumption.



 Comments   
Comment by Jeffrey Yemin [ 31/Mar/15 ]

Closing all resolved 3.0.0 issues, as 3.0.0 has been tagged and released.

Comment by Githook User [ 30/Jan/15 ]

Author:

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

Message: JAVA-1202: Dedicate a single thread scheduled executor to each server being monitored
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/cf68a430452bc91dc5500750729f5b312fcb5885

Comment by Githook User [ 01/Aug/14 ]

Author:

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

Message: JAVA-1202: Made connection volatile to remove race condition, and removed isRunning, since the executor is single threaded anyway.
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/65e8e30930f542ebd0b2e10667ee8b8351dc03e5

Comment by Githook User [ 01/Aug/14 ]

Author:

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

Message: JAVA-1202: Dedicate a single thread scheduled executor to each server being monitored, and , when changing the heartbeat frequency, ensure that the ServerStateNotifier is scheduled at most once by cancelling the existing schedule before creating the new one.
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/7d59cc8217eb6f60b238df98499ea4005ad430ee

Comment by Githook User [ 24/Jun/14 ]

Author:

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

Message: JAVA-1202: Dedicate a single thread scheduled executor to each server being monitored
Branch: 3.0.x
https://github.com/mongodb/mongo-java-driver/commit/cf68a430452bc91dc5500750729f5b312fcb5885

Comment by Githook User [ 07/May/14 ]

Author:

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

Message: JAVA-1202: Made connection volatile to remove race condition, and removed isRunning, since the executor is single threaded anyway.
Branch: 2.12.x
https://github.com/mongodb/mongo-java-driver/commit/65e8e30930f542ebd0b2e10667ee8b8351dc03e5

Comment by Githook User [ 06/May/14 ]

Author:

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

Message: JAVA-1202: Dedicate a single thread scheduled executor to each server being monitored, and , when changing the heartbeat frequency, ensure that the ServerStateNotifier is scheduled at most once by cancelling the existing schedule before creating the new one.
Branch: 2.12.x
https://github.com/mongodb/mongo-java-driver/commit/7d59cc8217eb6f60b238df98499ea4005ad430ee

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