Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-956

Legacy Find is not respecting limit

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.0.1
    • Affects Version/s: 1.0.0
    • Component/s: CRUD
    • Labels:
      None
    • Environment:
      Wire Protocol 3.2 (Azure CosmosDB)

      STR:
       The client should be connecting to a mongo instance such that

       top.SelectServer.Description.WireVersion.Max < 4

      Create and execute a query that specifies limit.

      Observe that a multiple of batchSize documents are returned, not the value of limit.

       * if limit < batchSize, batchSize is returned

       * if limit >= batchSize, n * batchSize is returned

      Notes:
      After a lengthy debugging session, we discovered the following. Hopefully it will guide you to a solution.

      • BatchCursor.Next() calls  legacyGetMore, which appends batchSize documents to currentBatch.Data
      • If limit < batchSize, numToReturn is a negative number. This may or may not be causing problems. Hard for us to tell as outsiders. This should probably be a short circuit condition
      • An extra network request is made. This causes more documents to be added to bc.currentBatch.Data. Limit is not being honored, as there is no logic similar to NewLegacyBatchCursor #118-#126 in legacyGetMore.

            Assignee:
            isabella.siu@mongodb.com Isabella Siu (Inactive)
            Reporter:
            jloy Jeremy Loy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: