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

delete command on mongos can return a negative count of deleted documents

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 3.2.10
    • Component/s: Querying
    • Query Optimization
    • ALL
    • Hide

      Create a collection named "test" with 2,147,483,648 documents. That's one more than the largest possible positive number that can be represented with a 32 bit signed integer.

      Run the following command:

      db.runCommand({ delete : "test", deletes : [ { q : {}, limit : 0 } ] })
      

      The expected result is:

      { "ok" : 1, "n" : 2147483648 }
      

      The actual result is:

      { "ok" : 1, "n" :  -2147483648 }
      
      Show
      Create a collection named "test" with 2,147,483,648 documents. That's one more than the largest possible positive number that can be represented with a 32 bit signed integer. Run the following command: db.runCommand({ delete : "test" , deletes : [ { q : {}, limit : 0 } ] }) The expected result is: { "ok" : 1, "n" : 2147483648 } The actual result is: { "ok" : 1, "n" : -2147483648 }

      When a very large number of documents matches the query the count of deleted documents can overflow and become negative.

      I have reproduced this with 3.2.10. It works correctly in 3.4.6.

      This ticket might be a duplicate, but I couldn't find a ticket for this.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            robert@mongodb.com Robert Stam
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated: