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

"assertion: bad char(s) in db name" when using blank space in a use db command

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.5.3
    • Affects Version/s: 1.4.3, 1.5.2
    • Component/s: Shell
    • None
    • Environment:
      OS X 10.6
      db version v1.4.3, pdfile version 4.5
      git version: 47ffbdfd53f46edeb6ff54bbb734783db7abc8ca
      sys info: Darwin erh2.10gen.cc 9.6.0 Darwin Kernel
    • OS X

      The problem happened when I accidentally typed "collection" between "use" and the name of the database I wanted to use. The relevant thing
      is the blank space, of course, and not the word "collection".

      The shell happily told me that it "switched to db collection docs". But, after I saved a document, I could no longer list the databases. I had to restart mongod to fix the problem.

      Here's my mongo session showing that the problem persists after restarting the shell:
      $ mongo
      MongoDB shell version: 1.4.3
      url: test
      connecting to: test
      type "help" for help
      > show dbs

      admin
      local
      > use collection docs

      switched to db collection docs
      > var doc1 =

      {"a":1}


      > db.coll.save(doc1)

      bad char(s) in db name
      > show dbs

      assert: assert failed : listDatabases failed:

      { "errmsg" : "assertion: bad char(s) in db name", "ok" : 0 }


      Thu Jun 10 23:17:39 JS Error: uncaught exception: assert failed :
      listDatabases failed:

      { "errmsg" : "assertion: bad char(s) in db name", "ok" : 0 }


      > bye

      $ mongo
      MongoDB shell version: 1.4.3
      url: test
      connecting to: test
      type "help" for help
      > show dbs

      assert: assert failed : listDatabases failed:

      { "errmsg" : "assertion: bad char(s) in db name", "ok" : 0 }


      Thu Jun 10 23:17:50 JS Error: uncaught exception: assert failed :
      listDatabases failed:

      { "errmsg" : "assertion: bad char(s) in db name", "ok" : 0 }

      And here's the console output:

      $ mongod
      mongod --help for help and startup options
      Thu Jun 10 23:16:17 Mongo DB : starting : pid = 22524 port = 27017
      dbpath = /data/db/ master = 0 slave = 0 64-bit
      Thu Jun 10 23:16:17 db version v1.4.3, pdfile version 4.5
      Thu Jun 10 23:16:17 git version:
      47ffbdfd53f46edeb6ff54bbb734783db7abc8ca
      Thu Jun 10 23:16:17 sys info: Darwin erh2.10gen.cc 9.6.0 Darwin Kernel
      Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/
      RELEASE_I386 i386 BOOST_LIB_VERSION=1_37
      Thu Jun 10 23:16:17 waiting for connections on port 27017
      Thu Jun 10 23:16:17 web admin interface listening on port 28017
      Thu Jun 10 23:16:25 connection accepted from 127.0.0.1:58211 #1
      Thu Jun 10 23:17:36 User Exception 10031:bad char(s) in db name
      Thu Jun 10 23:17:36 Caught Assertion in insert , continuing
      Thu Jun 10 23:17:36 insert collection docs.coll exception
      userassert:bad char(s) in db name 0ms
      Thu Jun 10 23:17:39 User Exception 10031:bad char(s) in db name
      Thu Jun 10 23:17:46 end connection 127.0.0.1:58211
      Thu Jun 10 23:17:48 connection accepted from 127.0.0.1:58227 #2
      Thu Jun 10 23:17:50 User Exception 10031:bad char(s) in db name

      And here's the data directory listing:
      $ ls -l /data/db
      total 8
      -rwxr-xr-x 1 rstewart admin 6 Jun 10 23:16 mongod.lock*

      After restarting mongod, the issue goes away.

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            robertstewart Robert Stewart
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: