[CSHARP-1082] Don't allow TagSets to be used with a ReadPreferenceMode of Primary Created: 08/Oct/14  Updated: 27/Oct/14  Resolved: 27/Oct/14

Status: Closed
Project: C# Driver
Component/s: Configuration
Affects Version/s: 1.9.2
Fix Version/s: 1.10, 2.0

Type: Improvement Priority: Minor - P4
Reporter: Robert Stam Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Minor Change

 Description   

When the ReadPreferenceMode is Primary it is not valid to supply tag sets, but the driver currently doesn't enforce that. There are multiple ways that such an invalid read preference might come to exist.

One example is:

var tagSets = new [] { new ReplicaSetTagSet { new ReplicaSetTag("dc", "ny") } };
var readPreference = new ReadPreference(ReadPreferenceMode.Primary, tagSets);

Another example is:

var builder = new MongoUrlBuilder("mongodb://localhost/?readPreference=primary;readpreferencetags=dc:ny");
var url = builder.ToMongoUrl();

There might be other ways.



 Comments   
Comment by Githook User [ 27/Oct/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1082: Throw ConfigurationException when tag sets are used without ReadPreferenceMode.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/bdaf0097afb7a2977510a94c232d203469ff7453

Comment by Githook User [ 27/Oct/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1082: Don't allow TagSets to be used with a ReadPreferenceMode of Primary.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/169add9f46cd93054d7cbb749c077ff0a5af613f

Comment by Githook User [ 27/Oct/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1082: Postpone throwing an exception for using tags with ReadPreferenceMode Primary until Freeze is called.
Branch: v1.x
https://github.com/mongodb/mongo-csharp-driver/commit/6de286b5063cd5e03e40a5357f193fb6c59068f9

Comment by Githook User [ 27/Oct/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1082: Don't allow TagSets to be used with a ReadPreferenceMode of Primary.
Branch: v1.x
https://github.com/mongodb/mongo-csharp-driver/commit/6811ee653f1572712bfaa84d7bbe0bf10de2dc56

Generated at Wed Feb 07 21:38:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.