-
Type: Improvement
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
The docs page in https://docs.mongodb.com/manual/tutorial/configure-replica-set-tag-sets/ contains an extensive tutorial & examples regarding the use of replica set tag sets. However, the semantics of the tags themselves are not clearly explained.
The tags look like a free-form document, where the "key" is the "tag", and the "value" could be anything the user wants.
However, this is not true. Both the key and the value of the tags are important. At least with regards to write concern.
For example, these tags:
> rs.conf() ... "members": [ { "_id": 0 "tags": { "production": "1", "ssd": "installed" } }, { "_id": 1 "tags": { "production": "2", "ssd": "installed" } } ], "settings": { "getLastErrorModes": { "production": { "production": 2 }, "ssd": { "ssd": 2 } } }
This replica set configuration would imply that writes using a writeConcern setting of either w:"production" or w:"ssd" would propagate the writes to both nodes before returning.
Inserting using w:"production", where the members have different values in the tags (i.e. "production": "1" and "production": "2"):
> db.test.insert({a:1},{writeConcern:{w:'production'}}) Inserted 1 record(s) in 26ms WriteResult({ "nInserted": 1 })
Inserting using w:"ssd", where the members have identical values in the tags (i.e. both members have "ssd": "installed"):
> db.test.insert({a:1},{writeConcern:{w:'ssd'}}) Inserted 1 record(s) in 3ms WriteResult({ "nInserted": 1, "writeConcernError": { "code": 100, "codeName": "CannotSatisfyWriteConcern", "errmsg": "Not enough nodes match write concern mode \"ssd\"" } })
This replica set tag semantics are counter-intuitive, and could be better explained in the docs. Some suggestions:
- Explain that the key and value of replica set tags are both significant in terms of writeConcern.
- Provide an example how writeConcern using custom tags could succeed or fail.
- related to
-
SERVER-28729 Ensure getLastErrorModes with replica set tags are satisfiable
- Backlog