Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-123

mongorestore allows period in database name

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.8.0-rc1
    • Affects Version/s: Legacy C++ Implementation
    • Component/s: mongorestore

      Forgetting that MongoDB doesn't allow periods in database names, I used the dot notation in an attempt to create a namespaced database during a recovery operation:

      mongorestore -h recoveryhost --port 27018 -d myproj.recovered .\dump\myproj
      connected to: recoveryhost:27018
      Tue Feb 18 08:02:49.206 .\dump\myproj\cases.bson
      Tue Feb 18 08:02:49.207         going into namespace [myproj.recovered.cases]
      Tue Feb 18 08:02:55.999                 Progress: 3233040/13928699      23%     (bytes)
      Tue Feb 18 08:02:58.774                 Progress: 6068390/13928699      43%     (bytes)
      Tue Feb 18 08:03:01.311                 Progress: 8599600/13928699      61%     (bytes)
      Tue Feb 18 08:03:05.602                 Progress: 10821744/13928699     77%     (bytes)
      Tue Feb 18 08:03:08.551                 Progress: 13772430/13928699     98%     (bytes)
      624 objects found
      Tue Feb 18 08:03:08.739         Creating index: { key: { _id: 1 }, ns: "myproj.recovered.cases", name: "_id_" }
      Tue Feb 18 08:03:09.021         Creating index: { key: { ident: 1 }, ns: "myproj.recovered.cases", name: "ident_1", background: true }
      Tue Feb 18 08:03:09.380         Creating index: { key: { questionnaire_name: 1, ident: 1 }, ns: "myproj.recovered.cases", name: "questionnaire_name_1_ident_1", background: true }
      Tue Feb 18 08:03:09.724         Creating index: { key: { survey_name: 1 }, ns: "myproj.recovered.cases", background: true, name: "survey_name_1" }
      Tue Feb 18 08:03:10.063         Creating index: { key: { questionnaire_name: 1, survey_id: 1, user_id: 1 }, ns: "myproj.recovered.cases", background: true, name: "questionnaire_name_1_survey_id_1_user_id_1" }
      Tue Feb 18 08:03:10.450         Creating index: { key: { questionnaire_name: 1, endtime: 1, dataset: 1 }, ns: "myproj.recovered.cases", background: true, name: "questionnaire_name_1_endtime_1_dataset_1" }
      Tue Feb 18 08:03:10.944         Creating index: { key: { questionnaire_name: 1, lastmodified: 1, dataset: 1 }, ns: "myproj.recovered.cases", background: true, name: "questionnaire_name_1_lastmodified_1_dataset_1" }
      Tue Feb 18 08:03:11.248         Creating index: { key: { questionnaire_name: 1, starttime: 1, dataset: 1 }, ns: "myproj.recovered.cases", background: true, name: "questionnaire_name_1_starttime_1_dataset_1" }
      Tue Feb 18 08:03:11.565         Creating index: { key: { region: 1, questionnaire_name: 1, survey_id: 1, user_id: 1 }, ns: "myproj.recovered.cases", name: "region_1_questionnaire_name_1_survey_id_1_user_id_1", background: true }
      assertion: 13106 nextSafe(): { $err: "bad or malformed command request?", code: 13530 }
      

      As you can see, using the period in the name caused the cases to be restored to the recovered.cases collection on the myproj database.

      As it turns out, this isn't a big deal, but it came as a surprise and could have been a big deal if 'recovered.cases' had already existed in the 'myproj' database.

      I suggest mongorestore should reject a database name with a period in it.

            Assignee:
            Unassigned Unassigned
            Reporter:
            jason.coombs@yougov.com Jason R. Coombs
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: