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

Btree cursor returns partial result without error if reIndex occurs during yield

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.4.10, 2.6.3
    • Component/s: Querying
    • None
    • ALL

      To reproduce, run setup(), then run reindex() and count() in parallel:

      var n = 1000
      
      function setup() {
          db.c.drop()
          for (var i=0; i<n; i++)
              db.c.insert({_id:i, x:i})
          db.getLastError()
      }
      
      function reindex() {
          for (;;) {
              db.c.reIndex()
              sleep(1)
          }
      }
      
      function count() {
          for (;;) {
              var nn = db.c.find().hint({_id:1}).batchSize(n).itcount()
              if (n != nn)
                  print('expected', n, 'got', nn)
          }
      }
      
      • As written above, with a large enough batchsize to avoid getmore, when the query yields it finishes without error and returns only a subset of the documents (which is always one less than a multiple of 128, the unit of work for yielding). If the query is not able to return full results it should return an error.
      • If the code is modified to use a small batch size so that getmores occurs, the query errors out with a CursorNotFound, which is acceptable.

            Assignee:
            tess.avitabile@mongodb.com Tess Avitabile (Inactive)
            Reporter:
            bruce.lucas@mongodb.com Bruce Lucas (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: