Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-568

Improve deprecation error for setSlaveOk

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 0.7.7
    • Fix Version/s: 0.10.0
    • Component/s: Shell API
    • Labels:
      None
    • Story Points:
      1
    • Documentation Changes:
      Not Needed

      Description

      Tab completion on a secondary won't work without setting the appropriate read preference.

      rs0 [direct: secondary]> db.slaTab completion error: MongoError: not master and slaveOk=false
          at MessageStream.messageHandler (/home/alex/Workspace/mongo/mongosh:46582:20)
          at MessageStream.emit (events.js:315:20)
          at MessageStream.EventEmitter.emit (domain.js:486:12)
          at processIncomingData (/home/alex/Workspace/mongo/mongosh:43478:12)
          at MessageStream._write (/home/alex/Workspace/mongo/mongosh:43374:5)
          at writeOrBuffer (_stream_writable.js:352:12)
          at MessageStream.Writable.write (_stream_writable.js:303:10)
          at Socket.ondata (_stream_readable.js:719:22)
          at Socket.emit (events.js:315:20)
          at Socket.EventEmitter.emit (domain.js:486:12) {
        topologyVersion: { processId: ObjectId("601c0d6951aabc0c661dc8d2"), counter: 4 },
        ok: 0,
        code: 13435,
        codeName: 'NotPrimaryNoSecondaryOk',
        '$clusterTime': {
          clusterTime: Timestamp(1, 1612451538),
          signature: {
            hash: Binary(Buffer.from("0000000000000000000000000000000000000000", "hex"), 0),
            keyId: 0
          }
        },
        operationTime: Timestamp(1, 1612451538)
      

      However SERVER-49990 removes `setSlaveOk` which users are used to and the MongoError still alludes to.

      rs0 [direct: secondary]> db.getMongo().setSlaveOk(true)
      MongoshDeprecatedError: [COMMON-10003] setSlaveOk is deprecated.
      

      Trying to set slaveOk does not point users to anything relevant. If you discover the alias (SERVER-49990) and try this the error is a little more helpful at least:

      rs0 [direct: secondary]> db.getMongo().setSecondaryOk(true)
      MongoshDeprecatedError: [COMMON-10003] Setting secondaryOk is deprecated, use setReadPref instead
      

      Making the setSlaveOk and setSecondaryOk errors the same would at least make this a little easier for users to action. Adding documentation links to the errors would be even better

        Attachments

          Activity

            People

            Assignee:
            sergey.petushkov Sergey Petushkov
            Reporter:
            alex.bevilacqua Alex Bevilacqua
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: