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

Validate should report records with invalid BSON in its command result

    • Fully Compatible
    • ALL
    • Execution Team 2020-06-29, Execution Team 2020-07-13

      Hi,

      Our MMAP 3.0.12 database is corrupted but we can't repair it using 3.0.12 tools.

      We have tried a number of techniques. Here are three:

      (1) We performed an initial sync which failed because of this error:

      I -        [rsSync] Assertion: 28531:Cloner: found corrupt document in redacted.guides: bson length doesn't match what we found in object with _id: ObjectId('56b54dd86ae840d1d150edaa')
      E REPL     [rsSync] 28531 Cloner: found corrupt document in redacted.guides: bson length doesn't match what we found in object with _id: ObjectId('56b54dd86ae840d1d150edaa')
      

      (2) We ran db.repairDatabase() but this failed because of this error:

      > db.repairDatabase()
      {
      	"errmsg" : "exception: BSONElement: bad type 126",
      	"code" : 10320,
      	"ok" : 0
      }
      

      (3a) We ran `mongodump --repair` on the corrupted collection (used the '-c' option)

      % mongodump -h localhost:27017 -d redacted -c guides --repair
      2016-05-15T11:25:01.385-0700    writing repair of redacted.guides to dump/redacted/guides.bson
      2016-05-15T11:28:17.799-0700            repair cursor found 161006 documents in redacted.guides
      2016-05-15T11:28:17.801-0700    writing redacted.guides metadata to dump/redacted/guides.metadata.json
      2016-05-15T11:28:17.870-0700    done dumping redacted.guides (0 documents)
      

      Then we attempted to mongorestore the collection:

      (3b) Running `mongorestore` (using the '-c' option) failed with "insertion error: EOF".

      % mongorestore -h localhost:27017 -d redacted -c guides2 dump/redacted/guides.bson
      
      2016-05-15T11:29:47.288-0700    checking for collection data in dump/redacted/guides.bson
      2016-05-15T11:29:47.291-0700    reading metadata file from dump/redacted/guides.metadata.json
      2016-05-15T11:29:47.292-0700    restoring redacted.guides2 from file dump/redacted/guides.bson
      2016-05-15T11:29:50.423-0700    [........................]  redacted.guides2  64.0 MB/1.7 GB  (3.7%)
      2016-05-15T11:29:53.290-0700    [#.......................]  redacted.guides2  80.0 MB/1.7 GB  (4.6%)
      2016-05-15T11:29:56.290-0700    [#.......................]  redacted.guides2  143.9 MB/1.7 GB  (8.3%)
      2016-05-15T11:29:59.330-0700    [##......................]  redacted.guides2  189.0 MB/1.7 GB  (10.9%)
      2016-05-15T11:30:02.326-0700    [##......................]  redacted.guides2  213.1 MB/1.7 GB  (12.2%)
      2016-05-15T11:30:05.355-0700    [###.....................]  redacted.guides2  271.9 MB/1.7 GB  (15.6%)
      2016-05-15T11:30:08.290-0700    [####....................]  redacted.guides2  303.9 MB/1.7 GB  (17.5%)
      2016-05-15T11:30:11.371-0700    [####....................]  redacted.guides2  351.9 MB/1.7 GB  (20.2%)
      2016-05-15T11:30:14.325-0700    [#####...................]  redacted.guides2  383.8 MB/1.7 GB  (22.0%)
      2016-05-15T11:30:17.435-0700    [######..................]  redacted.guides2  447.8 MB/1.7 GB  (25.7%)
      2016-05-15T11:30:20.438-0700    [#######.................]  redacted.guides2  511.7 MB/1.7 GB  (29.4%)
      2016-05-15T11:30:23.294-0700    [#######.................]  redacted.guides2  527.6 MB/1.7 GB  (30.3%)
      2016-05-15T11:30:26.290-0700    [########................]  redacted.guides2  591.4 MB/1.7 GB  (34.0%)
      2016-05-15T11:30:29.315-0700    [#########...............]  redacted.guides2  655.1 MB/1.7 GB  (37.6%)
      2016-05-15T11:30:32.294-0700    [#########...............]  redacted.guides2  709.3 MB/1.7 GB  (40.7%)
      2016-05-15T11:30:33.731-0700    Failed: restore error: redacted.guides2: error restoring from dump/redacted/guides.bson: insertion error: EOF
      

      (3c) We then tried `mongostore --objcheck --drop` but it failed with "invalid object: Document is corrupted"

      % mongorestore -h localhost:27017 -d redacted -c guides3 --objcheck dump/redacted/guides.bson
      
      2016-05-15T11:32:16.156-0700    checking for collection data in dump/redacted/guides.bson
      2016-05-15T11:32:16.810-0700    reading metadata file from dump/redacted/guides.metadata.json
      2016-05-15T11:32:16.811-0700    restoring redacted.guides3 from file dump/redacted/guides.bson
      2016-05-15T11:32:19.277-0700    [........................]  redacted.guides3  16.7 MB/1.7 GB  (1.0%)
      2016-05-15T11:32:22.319-0700    [........................]  redacted.guides3  43.2 MB/1.7 GB  (2.5%)
      2016-05-15T11:32:25.423-0700    [#.......................]  redacted.guides3  74.5 MB/1.7 GB  (4.3%)
      2016-05-15T11:32:28.189-0700    [#.......................]  redacted.guides3  79.9 MB/1.7 GB  (4.6%)
      2016-05-15T11:32:31.359-0700    [#.......................]  redacted.guides3  101.8 MB/1.7 GB  (5.8%)
      2016-05-15T11:32:34.698-0700    [#.......................]  redacted.guides3  139.4 MB/1.7 GB  (8.0%)
      2016-05-15T11:32:37.219-0700    [#.......................]  redacted.guides3  143.9 MB/1.7 GB  (8.3%)
      2016-05-15T11:32:40.333-0700    [##......................]  redacted.guides3  172.4 MB/1.7 GB  (9.9%)
      2016-05-15T11:32:43.602-0700    [##......................]  redacted.guides3  193.0 MB/1.7 GB  (11.1%)
      2016-05-15T11:32:46.255-0700    [##......................]  redacted.guides3  210.1 MB/1.7 GB  (12.1%)
      2016-05-15T11:32:49.552-0700    [###.....................]  redacted.guides3  232.8 MB/1.7 GB  (13.4%)
      2016-05-15T11:32:52.621-0700    [###.....................]  redacted.guides3  249.0 MB/1.7 GB  (14.3%)
      2016-05-15T11:32:55.341-0700    [###.....................]  redacted.guides3  267.6 MB/1.7 GB  (15.4%)
      2016-05-15T11:32:58.348-0700    [####....................]  redacted.guides3  291.4 MB/1.7 GB  (16.7%)
      2016-05-15T11:33:01.662-0700    [####....................]  redacted.guides3  315.2 MB/1.7 GB  (18.1%)
      2016-05-15T11:33:04.309-0700    [####....................]  redacted.guides3  335.1 MB/1.7 GB  (19.2%)
      2016-05-15T11:33:07.336-0700    [#####...................]  redacted.guides3  367.8 MB/1.7 GB  (21.1%)
      2016-05-15T11:33:10.220-0700    [#####...................]  redacted.guides3  384.2 MB/1.7 GB  (22.1%)
      2016-05-15T11:33:13.261-0700    [#####...................]  redacted.guides3  425.7 MB/1.7 GB  (24.5%)
      2016-05-15T11:33:16.220-0700    [######..................]  redacted.guides3  448.5 MB/1.7 GB  (25.8%)
      2016-05-15T11:33:19.496-0700    [######..................]  redacted.guides3  487.6 MB/1.7 GB  (28.0%)
      2016-05-15T11:33:22.220-0700    [#######.................]  redacted.guides3  527.7 MB/1.7 GB  (30.3%)
      2016-05-15T11:33:25.459-0700    [#######.................]  redacted.guides3  571.1 MB/1.7 GB  (32.8%)
      2016-05-15T11:33:28.276-0700    [########................]  redacted.guides3  623.4 MB/1.7 GB  (35.8%)
      2016-05-15T11:33:31.433-0700    [#########...............]  redacted.guides3  679.5 MB/1.7 GB  (39.0%)
      2016-05-15T11:33:34.195-0700    [#########...............]  redacted.guides3  704.4 MB/1.7 GB  (40.5%)
      2016-05-15T11:33:34.909-0700    Failed: restore error: redacted.guides3: error restoring from dump/redacted/guides.bson: insertion error: invalid object: Document is corrupted
      

      Let us know what else would be helpful here.

      Thanks,
      Angela

            Assignee:
            shinyee.tan@mongodb.com Shin Yee Tan
            Reporter:
            akung0324 Angela Shulman
            Votes:
            3 Vote for this issue
            Watchers:
            17 Start watching this issue

              Created:
              Updated:
              Resolved: