-
Type:
Bug
-
Resolution: Done
-
Priority:
Critical - P2
-
Affects Version/s: 0.96.4
-
Component/s: None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
I have a replica set with 3 nodes:
{
"_id" : "replset",
"version" : 3,
"members" : [
{
"_id" : 0,
"host" : "outcoldx:28001",
"tags" : {
"instance" : "11111111-1111-1111-1111-111111111111"
}
},
{
"_id" : 1,
"host" : "outcoldx:28002",
"tags" : {
"instance" : "11111111-1111-1111-1111-111111111112"
}
},
{
"_id" : 2,
"host" : "outcoldx:28003",
"tags" : {
"instance" : "11111111-1111-1111-1111-111111111113"
}
}
]
}
1. It seems like having "readPreference=nearest" and "readPreferenceTags=instance:11111111-1111-1111-1111-111111111113" in connection strings does not change readPreference behavior, read preference needs to be explicitly set via one of the mongoc_client_set_read_prefs or mongoc_collection_set_read_prefs. Which is fine, not great, but fine.
2. I tried to explicitly set mongoc_client_set_read_prefs with tags, but it did not work, because it seems like mongoc driver never loads tags for server from replica set configuration, because private function "_score_tags" from mongoc-read-prefs.c always has empty tags for nodes.
Also I attached an example which I used to verify that. When I use mongoc_read_prefs_t with tags - this example fails because it cannot find node, which should be used for search.