[GODRIVER-2205] Empty read preference tag sets are incorrectly skipped during command construction Created: 25/Oct/21  Updated: 28/Oct/23  Resolved: 01/Nov/21

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.7.4

Type: Bug Priority: Critical - P2
Reporter: Divjot Arora (Inactive) Assignee: Matt Dale
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File main.go     File main.py    
Issue Links:
Depends
Related
related to GODRIVER-2305 Empty readPreferenceTags Connection F... Closed

 Description   

When creating read preference documents for commands, the driver skips empty tag sets here. However, per the server selection spec, an empty tag set is semantically important:

A tag set that is an empty document matches any server, because the empty tag set is a subset of any tag set. This means the default tag_sets parameter ([{}]) matches all servers.

Empty tag sets can be used as a fallback to match any server if previous tag sets did not match. The driver's skip behavior causes issues when connected to sharded clusters because the empty tag set will not be included in the $readPreference document, so the mongos will return a FailedToSatisfyReadPreference error if no servers matched the previous sets.

I've attached Go and Python versions of a script that demonstrates this issue. If connected to a sharded cluster with a mongos running on localhost:27017, the Go script fails and the Python one succeeds.



 Comments   
Comment by Githook User [ 01/Nov/21 ]

Author:

{'name': 'Matt Dale', 'email': '9760375+matthewdale@users.noreply.github.com', 'username': 'matthewdale'}

Message: GODRIVER-2205 Retain empty tag sets when building a read preference document. (#787)
Branch: release/1.7
https://github.com/mongodb/mongo-go-driver/commit/b1763dbc706250852447d6729e1b93bb3c8a9f58

Comment by Githook User [ 01/Nov/21 ]

Author:

{'name': 'Matt Dale', 'email': '9760375+matthewdale@users.noreply.github.com', 'username': 'matthewdale'}

Message: GODRIVER-2205 Retain empty tag sets when building a read preference document. (#787)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/34dde800748e03c76c46fbdbb54ea1c5a26b32c9

Comment by Matt Dale [ 30/Oct/21 ]

PR: https://github.com/mongodb/mongo-go-driver/pull/787

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