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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: 3.2.10
    • Fix Version/s: Backlog
    • Component/s: Querying
    • Operating System:
      ALL
    • Steps To Reproduce:
      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 }

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-server-query Backlog - Query Team
              Reporter:
              rstam Robert Stam
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              10 Start watching this issue

                Dates

                Created:
                Updated: