'Connecting MongoDb cluster with tagset when members don't have tags defined
I have a .Net client connecting to MongoDb cluster. We are using the tagset feature to select specific members with the following code:
new ReadPreference(ReadPreferenceMode.Secondary, new List<TagSet> { new TagSet(someTag), new TagSet() })
In the Tip in https://www.mongodb.com/docs/manual/core/read-preference-tags/ it says:
To avoid an error if no members match any of the tag specifications, you can add an empty document { } as the last element of the tag set to read from any eligible member.
But if our servers don't have any tags configured at all, the client returns the following error instead to use the empty TagSet and connect to one of them anyway:
System.TimeoutException: A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = ReadPreferenceServerSelector{ ReadPreference = { Mode : Secondary, TagSets : [{ test : somevalue }, { }] } }
I'm looking for a way to configure the client in such way that in case the tags don't match or don't exist on the server, it will still fall back to any of the available members.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
