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

getCmdLineOpts returns boolean values as strings for options that come from a config file

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.5.3
    • Affects Version/s: 2.4.6
    • Component/s: None
    • None
    • Environment:
      Mac OS X 10.8.5
    • ALL
      1. Create a mongod config file with some boolean options
      2. Start the mongod using the config file
      3. Connect to the mongod and run getCmdLineOpts
    • None
    • 0
    • None
    • None
    • None
    • None
    • None
    • None

      In the "parsed" section of its response, getCmdLineOpts returns boolean values as strings for options that come from a config file. Take the following as an example.

      When specifying all options on the command line, getCmdLineOpts properly reports boolean options to have boolean values:

      $ mongod --dbpath=/tmp/mongodb --nojournal --noprealloc --oplogSize=64 --port=9001 --smallfiles --fork --logpath=/tmp/mongodb.log
      note: noprealloc may hurt performance in many applications
      about to fork child process, waiting until server is ready for connections.
      forked process: 53615
      all output going to: /tmp/mongodb.log
      child process started successfully, parent exiting
      $ mongo localhost:9001
      MongoDB shell version: 2.4.6
      connecting to: localhost:9001/test
      Server has startup warnings: 
      Wed Oct  2 16:38:32.307 [initandlisten] 
      Wed Oct  2 16:38:32.307 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
      > use admin
      switched to db admin
      > db.admin.runCommand({getCmdLineOpts: 1})
      {
      	"argv" : [
      		"mongod",
      		"--dbpath=/tmp/mongodb",
      		"--nojournal",
      		"--noprealloc",
      		"--oplogSize=64",
      		"--port=9001",
      		"--smallfiles",
      		"--fork",
      		"--logpath=/tmp/mongodb.log"
      	],
      	"parsed" : {
      		"dbpath" : "/tmp/mongodb",
      		"fork" : true,
      		"logpath" : "/tmp/mongodb.log",
      		"nojournal" : true,
      		"noprealloc" : true,
      		"oplogSize" : 64,
      		"port" : 9001,
      		"smallfiles" : true
      	},
      	"ok" : 1
      }
      > 
      

      But when started with a config file, the boolean options that come from the config file are reported to have a string values:

      $ cat /tmp/mongod.conf 
      dbpath = /tmp/mongodb
      nojournal = true
      noprealloc = true
      oplogSize = 64
      port = 9001
      smallfiles = true
      logpath = /tmp/mongod.log
      $ mongod --fork -f /tmp/mongod.conf 
      note: noprealloc may hurt performance in many applications
      about to fork child process, waiting until server is ready for connections.
      forked process: 54279
      all output going to: /tmp/mongod.log
      child process started successfully, parent exiting
      $ mongo localhost:9001
      MongoDB shell version: 2.4.6
      connecting to: localhost:9001/test
      Server has startup warnings: 
      Wed Oct  2 16:44:39.921 [initandlisten] 
      Wed Oct  2 16:44:39.921 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
      > use admin
      switched to db admin
      > db.admin.runCommand({getCmdLineOpts: 1})
      {
      	"argv" : [
      		"mongod",
      		"--fork",
      		"-f",
      		"/tmp/mongod.conf"
      	],
      	"parsed" : {
      		"config" : "/tmp/mongod.conf",
      		"dbpath" : "/tmp/mongodb",
      		"fork" : true,
      		"logpath" : "/tmp/mongod.log",
      		"nojournal" : "true",
      		"noprealloc" : "true",
      		"oplogSize" : 64,
      		"port" : 9001,
      		"smallfiles" : "true"
      	},
      	"ok" : 1
      }
      > 
      

      Mongo correctly returns integer values as integers, even when specified via a config file. It's just boolean values that it appears to return as strings.

      Note that this bug is also apparent in the example given for getCmdLineOpts at http://docs.mongodb.org/manual/reference/command/getCmdLineOpts/

            Assignee:
            sverch Shaun Verch (Inactive)
            Reporter:
            tim.olsen@mongodb.com Timothy Olsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: