[CDRIVER-3636] maxWireVersion check for MaxStalenessSeconds does not exclude PossiblePrimary Created: 27/Apr/20 Updated: 28/Oct/23 Resolved: 13/Sep/21 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | None |
| Affects Version/s: | 1.16.2 |
| Fix Version/s: | 1.19.1 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Anton Neznaienko | Assignee: | Kevin Albertson |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | post-5.0 | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
php-cli 7.4.5 mongodb MongoDB support => enabled Directive => Local Value => Master Value |
||
| Case: | (copied to CRM) |
| Description |
|
Summary
Servers of type PossiblePrimary must not be considered in this check, since they have no known maxWireVersion. libmongoc does not exclude PossiblePrimary in mongoc_topology_description_lowest_max_wire_version. This may result in incorrect errors when MaxStalenessSeconds is specified in the read preference. If there is a PossiblePrimary server in the topology description, server selection will fail until the server is rediscovered. Original report Recently we've added maxStalenessSeconds option to PHP Driver configuration and noticed occasional erroneous log messages. Not all servers support maxStalenessSeconds message is displayed in server logs. But Not all servers support maxStalenessSeconds should not happen IMHO.
Running a few instances of this script under debugger I was able to stop at bp set at https://github.com/mongodb/mongo-c-driver/blob/1.16.2/src/libmongoc/src/mongoc/mongoc-topology.c#L655 Here is a lldb dump out of there:
As you see max_wire_version is zero. I think that despite mongoc_topology_description_lowest_max_wire_version doc says that owning toplogy mutex should be held, neither mongoc_topology_compatible nor https://github.com/mongodb/mongo-c-driver/blob/1.16.2/src/libmongoc/src/mongoc/mongoc-topology.c#L859 holds mutex. |
| Comments |
| Comment by Githook User [ 13/Sep/21 ] | ||||||||||||||||||||||||
|
Author: {'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}Message: Do not check PossiblePrimary servers in the maxWireVersion check | ||||||||||||||||||||||||
| Comment by Githook User [ 13/Sep/21 ] | ||||||||||||||||||||||||
|
Author: {'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}Message: Do not check PossiblePrimary servers in the maxWireVersion check | ||||||||||||||||||||||||
| Comment by Anton Neznaienko [ 08/Sep/21 ] | ||||||||||||||||||||||||
|
Thanks Kevin, Will try as soon as it's released! | ||||||||||||||||||||||||
| Comment by Kevin Albertson [ 04/Sep/21 ] | ||||||||||||||||||||||||
|
Hi neanton@gmail.com, thank you again for the detailed repro! Modeling that example, I was able to reproduce in the C driver. This appears to be a bug in the maxWireVersion check for MaxStalenessSeconds. A fix should be included in the next patch release, 1.19.1. | ||||||||||||||||||||||||
| Comment by Kevin Albertson [ 24/Feb/21 ] | ||||||||||||||||||||||||
|
Hi neanton@gmail.com! Thank you for the detailed report and repro, and for verifying this with the latest PHP extension. We will look into this soon. | ||||||||||||||||||||||||
| Comment by Anton Neznaienko [ 24/Feb/21 ] | ||||||||||||||||||||||||
|
This issue is still present with the latest mongodb php extension:
|