[CDRIVER-2237] Server not invalidated in topology if command fails Created: 08/Aug/17  Updated: 28/Oct/23  Resolved: 25/Aug/17

Status: Closed
Project: C Driver
Component/s: libmongoc
Affects Version/s: None
Fix Version/s: 1.8.0

Type: Bug Priority: Major - P3
Reporter: Patrick Freed Assignee: A. Jesse Jiryu Davis
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to CXX-1409 Add implementation of Change Streams Closed
related to CXX-1420 Simplify change stream server selection Closed
is related to CDRIVER-2174 _mongoc_cluster_check_interval() shou... Closed

 Description   

In mongoc_cluster_run_command_internal, and possibly in _mongoc_cluster_stream_for_server, we call mongoc_cluster_disconnect_node if we get a network error, but we don't always call mongoc_topology_invalidate_server, so we can continue to do failing operations on the same server without first re-scanning the topology.

The Server Discovery and Monitoring spec says:

If there is a network timeout on the connection after the handshake completes, the client MUST NOT mark the server Unknown. (A timeout may indicate a slow operation on the server, rather than an unavailable server.) If, however, there is some other network error on the connection after the handshake completes, the client MUST replace the server's description with a default ServerDescription of type Unknown, and fill the ServerDescription's error field with useful information, the same as if an error or timeout occurred before the handshake completed.

Audit all mongoc_cluster_disconnect_node calls and check if they properly call mongoc_topology_invalidate_server after non-timeout network errors. Consider a refactoring to make this mistake less likely. Perhaps add a bool to mongoc_cluster_disconnect_node to tell it to call mongoc_topology_invalidate_server.



 Comments   
Comment by Ramon Fernandez Marina [ 12/Sep/17 ]

Author:

{'username': u'ajdavis', 'name': u'A. Jesse Jiryu Davis', 'email': u'jesse@mongodb.com'}

Message:CDRIVER-2237 distinguish network timeout and error
Branch:master
https://github.com/mongodb/mongo-c-driver/commit/e66b022948a4ada936628e75a662daf6c913c22e

Comment by Githook User [ 25/Aug/17 ]

Author:

{'email': 'jesse@mongodb.com', 'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis'}

Message: CDRIVER-2237 re-check servers after network errors

Obeying the Server Discovery and Monitoring Spec, mark a server Unknown
after any network besides a timeout, re-check the server before using it
again.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/74600b68eb7c6293c962eab752e114f4d69446db

Generated at Wed Feb 07 21:14:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.