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

.count() returns wrong value

    • Type: Icon: Question Question
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.2.22
    • Component/s: Querying
    • Labels:
      None

      While debugging a problem in an app I found that it is caused by a wrong value returned from Mongo. So I end up have a collection for which .count() always returns 136 while the collection is empty.

      Here is what I see in the mongo terminal:

       

      > db.ReadStats.findOne() — normal collection
      null
      > db.ReadStats.count()
      0
      > db.PendingRecords.findOne() — broken collection?
      null
      > db.PendingRecords.count()
      136

       

      When I do dump — this collection is saved as PendingRecords.bson 0 B file. So it is really empty. And according to our log of logic actions, it really should be empty.

      > db.repairDatabase()
      { "ok" : 1 }
      > db.PendingRecords.count()
      0

      Repair helped, but what could go wrong? What should we do to do not encounter this again? Because it just breaks our app (

            Assignee:
            Unassigned Unassigned
            Reporter:
            inversion Yura Inversion
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: