title: Worrying Invalid BSONObj errors when running db.stats() on a production MongoDB
body: <p>Our production database (2.2.1 on 64bit debian) is throwing the following error below when we run db.stats():</p>
  
  <pre><code>&gt; db.stats()
  {
      "errmsg" : "exception: Invalid BSONObj size: 0 (0x00000000) first element: EOO",
      "code" : 10334,
      "ok" : 0
  }
  </code></pre>
  
  <p>The following appears in our logs: </p>
  
  <pre><code>Fri Feb  1 16:28:46 [conn4081] Assertion: 10334:Invalid BSONObj size: 0 (0x00000000) first element: EOO
  0xaf8c41 0xabedb9 0xabef3c 0x571fb7 0x6e880d 0x6f6411 0x6e8321 0x6e9cb0 0x6eab4c 0x830028 0x83376b 0x7b0b0d 0x7b20e2 0x56fe42 0xae6ed1 0x7fe7645378ba 0x7fe7638eb02d
   /opt/mongodb/bin/mongod(_ZN5mongo15printStackTraceERSo+0x21) [0xaf8c41]
   /opt/mongodb/bin/mongod(_ZN5mongo11msgassertedEiPKc+0x99) [0xabedb9]
   /opt/mongodb/bin/mongod() [0xabef3c]
   /opt/mongodb/bin/mongod(_ZNK5mongo7BSONObj14_assertInvalidEv+0x497) [0x571fb7]
   /opt/mongodb/bin/mongod() [0x6e880d]
   /opt/mongodb/bin/mongod(_ZN5mongo7DBStats3runERKSsRNS_7BSONObjEiRSsRNS_14BSONObjBuilderEb+0x321) [0x6f6411]
   /opt/mongodb/bin/mongod(_ZN5mongo12_execCommandEPNS_7CommandERKSsRNS_7BSONObjEiRNS_14BSONObjBuilderEb+0x51) [0x6e8321]
   /opt/mongodb/bin/mongod(_ZN5mongo11execCommandEPNS_7CommandERNS_6ClientEiPKcRNS_7BSONObjERNS_14BSONObjBuilderEb+0xe70) [0x6e9cb0]
   /opt/mongodb/bin/mongod(_ZN5mongo12_runCommandsEPKcRNS_7BSONObjERNS_11_BufBuilderINS_16TrivialAllocatorEEERNS_14BSONObjBuilderEbi+0x2ac) [0x6eab4c]
   /opt/mongodb/bin/mongod(_ZN5mongo11runCommandsEPKcRNS_7BSONObjERNS_5CurOpERNS_11_BufBuilderINS_16TrivialAllocatorEEERNS_14BSONObjBuilderEbi+0x38) [0x830028]
   /opt/mongodb/bin/mongod(_ZN5mongo8runQueryERNS_7MessageERNS_12QueryMessageERNS_5CurOpES1_+0xc0b) [0x83376b]
   /opt/mongodb/bin/mongod() [0x7b0b0d]
   /opt/mongodb/bin/mongod(_ZN5mongo16assembleResponseERNS_7MessageERNS_10DbResponseERKNS_11HostAndPortE+0x3a2) [0x7b20e2]
   /opt/mongodb/bin/mongod(_ZN5mongo16MyMessageHandler7processERNS_7MessageEPNS_21AbstractMessagingPortEPNS_9LastErrorE+0x82) [0x56fe42]
   /opt/mongodb/bin/mongod(_ZN5mongo3pms9threadRunEPNS_13MessagingPortE+0x411) [0xae6ed1]
   /lib/libpthread.so.0(+0x68ba) [0x7fe7645378ba]
   /lib/libc.so.6(clone+0x6d) [0x7fe7638eb02d]
  </code></pre>
  
  <p>We are getting quite concerned over this. Any ideas? All I can find on the net is old and non-conclusive.</p>
  
  <p>Here is some more information: </p>
  
  <pre><code>&gt; db.serverStatus()
  {
      "host" : "hellboy",
      "version" : "2.2.1",
      "process" : "mongod",
      "pid" : 1432,
      "uptime" : 2672006,
      "uptimeMillis" : NumberLong("2672006216"),
      "uptimeEstimate" : 2626689,
      "localTime" : ISODate("2013-02-01T23:03:16.304Z"),
      "locks" : {
          "." : {
              "timeLockedMicros" : {
                  "R" : NumberLong(333024517),
                  "W" : NumberLong("54808066962")
              },
              "timeAcquiringMicros" : {
                  "R" : NumberLong("30969573082"),
                  "W" : NumberLong("4107434021")
              }
          },
          "admin" : {
              "timeLockedMicros" : {
                  "r" : NumberLong(5942684),
                  "w" : NumberLong(0)
              },
              "timeAcquiringMicros" : {
                  "r" : NumberLong(48432),
                  "w" : NumberLong(0)
              }
          },
          "local" : {
              "timeLockedMicros" : {
                  "r" : NumberLong(1109128),
                  "w" : NumberLong(0)
              },
              "timeAcquiringMicros" : {
                  "r" : NumberLong(82283399),
                  "w" : NumberLong(0)
              }
          },
          "gc" : {
              "timeLockedMicros" : {
                  "r" : NumberLong("171460799918"),
                  "w" : NumberLong("171384959016")
              },
              "timeAcquiringMicros" : {
                  "r" : NumberLong("1816006512260"),
                  "w" : NumberLong("3169374123999")
              }
          }
      },
      "globalLock" : {
          "totalTime" : NumberLong("2672006216000"),
          "lockTime" : NumberLong("54808066962"),
          "currentQueue" : {
              "total" : 0,
              "readers" : 0,
              "writers" : 0
          },
          "activeClients" : {
              "total" : 0,
              "readers" : 0,
              "writers" : 0
          }
      },
      "mem" : {
          "bits" : 64,
          "resident" : 4212,
          "virtual" : 443165,
          "supported" : true,
          "mapped" : 221237,
          "mappedWithJournal" : 442474
      },
      "connections" : {
          "current" : 364,
          "available" : 455
      },
      "extra_info" : {
          "note" : "fields vary by platform",
          "heap_usage_bytes" : 77840056,
          "page_faults" : 15189196
      },
      "indexCounters" : {
          "btree" : {
              "accesses" : 1490093267,
              "hits" : 1490093267,
              "misses" : 0,
              "resets" : 0,
              "missRatio" : 0
          }
      },
      "backgroundFlushing" : {
          "flushes" : 36144,
          "total_ms" : 614413596,
          "average_ms" : 16999.048140770254,
          "last_ms" : 352,
          "last_finished" : ISODate("2013-02-01T23:02:43.221Z")
      },
      "cursors" : {
          "totalOpen" : 5,
          "clientCursors_size" : 5,
          "timedOut" : 3,
          "totalNoTimeout" : 5
      },
      "network" : {
          "bytesIn" : 53731292608,
          "bytesOut" : NumberLong("2215346701908"),
          "numRequests" : 264535004
      },
      "opcounters" : {
          "insert" : 83515158,
          "query" : 141076950,
          "update" : 21415981,
          "delete" : 98,
          "getmore" : 685956,
          "command" : 18499441
      },
      "asserts" : {
          "regular" : 0,
          "warning" : 57,
          "msg" : 0,
          "user" : 0,
          "rollovers" : 0
      },
      "writeBacksQueued" : false,
      "dur" : {
          "commits" : 30,
          "journaledMB" : 0,
          "writeToDataFilesMB" : 0,
          "compression" : 0,
          "commitsInWriteLock" : 0,
          "earlyCommits" : 0,
          "timeMs" : {
              "dt" : 3074,
              "prepLogBuffer" : 0,
              "writeToJournal" : 0,
              "writeToDataFiles" : 0,
              "remapPrivateView" : 0
          }
      },
      "recordStats" : {
          "accessesNotInMemory" : 3070244,
          "pageFaultExceptionsThrown" : 1124345,
          "admin" : {
              "accessesNotInMemory" : 0,
              "pageFaultExceptionsThrown" : 0
          },
          "gc" : {
              "accessesNotInMemory" : 3070244,
              "pageFaultExceptionsThrown" : 1124345
          },
          "local" : {
              "accessesNotInMemory" : 0,
              "pageFaultExceptionsThrown" : 0
          }
      },
      "ok" : 1
  }
  </code></pre>