Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-10032

Clarify the semantics of replica set tags

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • None
    • None
    • None
    • true

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              kevin.adistambha@mongodb.com Kevin Adistambha
              kevin.adistambha@mongodb.com Kevin Adistambha
              Jonathan Dahl Jonathan Dahl
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                5 years, 17 weeks, 5 days ago