[JAVA-5269] Possible bug in Heartbeat Socket settings Created: 12/Dec/23  Updated: 15/Dec/23  Resolved: 15/Dec/23

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

Type: Bug Priority: Minor - P4
Reporter: Kenneth Robinson Assignee: Unassigned
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Description   

Summary

While adjusting socketsettings, we noticed that heartbeat socketsettings were also getting modified.  This appears to be intentional and makes sense.  However, this code appears to be bugged, in that the connect timeout from socket settings is being propagated to both the connect and read timeouts of the heartbeat.  From MongoClientSettings:

heartbeatSocketSettings = SocketSettings.builder()
.readTimeout(builder.heartbeatSocketTimeoutMS == 0
? socketSettings.getConnectTimeout(MILLISECONDS) : builder.heartbeatSocketTimeoutMS,
MILLISECONDS)
.connectTimeout(builder.heartbeatConnectTimeoutMS == 0
? socketSettings.getConnectTimeout(MILLISECONDS) : builder.heartbeatConnectTimeoutMS,
MILLISECONDS)

Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

Java 4.11.1 

How to Reproduce

Configure any new MongoClient, specifying socket settings with a non-zero connect timeout.  Note that this propagates into the heartbeat socket settings read timeout.

 



 Comments   
Comment by Kenneth Robinson [ 15/Dec/23 ]

Fair enough!  I had gone trolling back through older drivers and noticed it had been like that for a long time.  Can I maybe recommend some comments/javadoc in the driver though?  Its a bit of a surprise to see!

Comment by Jeffrey Yemin [ 15/Dec/23 ]

Hi kroc8@allstate.com, while it may appear like a bug, the behavior is intentional. You can find the rationale for it here: https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-monitoring.rst#socket-timeout-for-monitoring-is-connecttimeoutms

Comment by PM Bot [ 12/Dec/23 ]

Hi kroc8@allstate.com, thank you for reporting this issue! The team will look into it and get back to you soon.

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