[JAVA-4743] High monitor connection churn during quiesce period Created: 29/Sep/22  Updated: 28/Oct/23  Resolved: 29/Sep/22

Status: Closed
Project: Java Driver
Component/s: SDAM
Affects Version/s: None
Fix Version/s: 4.7.2

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

Issue Links:
Related
related to DRIVERS-2458 Add test that monitors do not create ... Backlog
Case:
Documentation Changes: Not Needed

 Description   

Summary

When a server enters quiesce mode, the Java driver will repeatedly open and close monitoring connections to that server in a tight loop, leading to high connection churn.

This affects Java driver 4.7.0, but could date as far back as 4.1.
Affects MongoDB 5.0+ replica sets and sharded clusters.

How to Reproduce

  • Start a 5.0 replica set
  • Connect the driver to a secondary with directConnection=true, enable logging
  • Execute a ping command
  • Sleep the thread
  • Kill the secondary the driver is connected to (SIGTERM)
  • Observe repeated connection creation for the duration of the quiesce period

Additional Background

See this comment for additional information.



 Comments   
Comment by Jeffrey Yemin [ 29/Sep/22 ]

Author:

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

Message: Add missing condition for whether to sleep in server monitor

There is a missing check in an already-complicated conditinal statement
for whether to sleep in the server monitor before executing the next check.

The condition is included in the server discovery and monitoring specification
pseudo-code but missing in the driver, and there are currently no tests for it.

This commits adds the missing condition to the conditional statement. Effectively,
this will reduce the number of sockets that the monitor opens on a server that is
in the process of shutting down but still accepting connections.

JAVA-4730
Branch: 4.7.x
https://github.com/mongodb/mongo-java-driver/commit/7d8d94d06aec460b69e46e3eb20d97d00a2ce352

Comment by Jeffrey Yemin [ 29/Sep/22 ]

Author:

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

Message: Add missing condition for whether to sleep in server monitor

There is a missing check in an already-complicated conditinal statement
for whether to sleep in the server monitor before executing the next check.

The condition is included in the server discovery and monitoring specification
pseudo-code but missing in the driver, and there are currently no tests for it.

This commits adds the missing condition to the conditional statement. Effectively,
this will reduce the number of sockets that the monitor opens on a server that is
in the process of shutting down but still accepting connections.

JAVA-4730
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/e8bc843f214704e5891e24b44489896109ba0200

Generated at Thu Feb 08 09:02:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.