[SERVER-11011] getCmdLineOpts returns boolean values as strings for options that come from a config file Created: 02/Oct/13  Updated: 11/Jul/16  Resolved: 03/Nov/13

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 2.4.6
Fix Version/s: 2.5.3

Type: Bug Priority: Minor - P4
Reporter: Timothy Olsen (Inactive) Assignee: Shaun Verch
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Mac OS X 10.8.5


Operating System: ALL
Steps To Reproduce:
  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
Participants:

 Description   

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/


Generated at Thu Feb 08 03:24:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.