Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-35617

Unpleasant db.enableFreeMonitoring "not master" error on newly launched mongod

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Trivial - P5
    • Resolution: Fixed
    • Affects Version/s: 4.0.0-rc5
    • Fix Version/s: 4.0.2, 4.1.2
    • Component/s: Shell
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Backport Requested:
      v4.0
    • Sprint:
      Platforms 2018-08-13

      Description

      I launched a new mongod process with an empty database directory:

      $ mongod --dbpath /tmp/db --replSet rs
      

      Upon accessing the mongod with the shell, I saw a blurb inviting me to run db.enableFreeMonitoring(). I happened to run this before rs.initiate() and was greeted with the following, unpleasant error:

      $ mongo
      MongoDB shell version v4.0.0-rc5
      connecting to: mongodb://127.0.0.1:27017
      MongoDB server version: 4.0.0-rc5
      ---
      Enable MongoDB's free cloud-based monitoring service to collect and display
      metrics about your deployment (disk utilization, CPU, operation statistics,
      etc).
       
      The monitoring data will be available on a MongoDB website with a unique
      URL created for you. Anyone you share the URL with will also be able to
      view this page. MongoDB may use this information to make product
      improvements and to suggest MongoDB products and deployment options to you.
       
      To enable free monitoring, run the following command:
      db.enableFreeMonitoring()
      ---
       
      > db.enableFreeMonitoring()
      2018-06-15T13:00:32.014-0400 E QUERY    [js] Error: command failed: {
      	"operationTime" : Timestamp(0, 0),
      	"ok" : 0,
      	"errmsg" : "not master",
      	"code" : 10107,
      	"codeName" : "NotMaster",
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(0, 0),
      		"signature" : {
      			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      			"keyId" : NumberLong(0)
      		}
      	}
      } :
      _getErrorWithCode@src/mongo/shell/utils.js:25:13
      doassert@src/mongo/shell/assert.js:18:14
      _assertCommandWorked@src/mongo/shell/assert.js:534:17
      assert.commandWorked@src/mongo/shell/assert.js:618:16
      DB.prototype.enableFreeMonitoring@src/mongo/shell/db.js:1955:1
      @(shell):1:1
      >
      

      It may be trivial to improve the user experience here by having db.enableFreeMonitoring check that the active connection is a primary before attempting to run the setFreeMonitoring command.

        Attachments

          Activity

            People

            Assignee:
            mark.benvenuto Mark Benvenuto
            Reporter:
            jmikola Jeremy Mikola
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: