Description
Hello globalsign team
I need help with how to specify empty read preference tags using mgo.DialInfo.ReadPreference.TagSets
According to mongodb documentation: https://docs.mongodb.com/manual/reference/method/Mongo.setReadPref/
If the replica set cannot satisfy the first tag set, the client will attempt to use the second read preference. Each tag set can contain zero or more field/value tag pairs, with an "empty" document acting as a wildcard which matches a replica set member with any tag set or no tag set.
So IF the empty tag set is provided, the fail over logic should match any repl set member, but ONLY if it’s unable to match the first tag set
I am specifying the tag sets as follows:
o.DialInfo.ReadPreference.TagSets = []bson.D{{bson.DocElem{Name: "foo", Value: "bar"}}, {}}
it seems that with the above configuration, your BestFit
function always returns default server (primary in my case, which does not have tags foo:bar), because it is matched on the empty tag, even though the actual server with tags foo:bar is reachable, but it is not returned as BestFit. I hope, I’m just not specifying the tagSets correctly. Could someone please clarify this for me.
Thanks.