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

changeStreamCursor.hasNext() takes longer when returning false

    • Type: Icon: Question Question
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 6.0.13
    • Component/s: None
    • Labels:
      None
    • Query Execution

      I am writing a no-passthough jstest opening and closing 960 change stream cursors with different options. The test starts and stops a minimalistic ShardingTest instance (1 mongos, 1 config-mongod, 1 shard-mongod) within the JavaScript file.

      I've noticed that changeStreamCursor.hasNext() takes considerably longer (3 to 10 times) when the result is 'false' (no change events to return).

      I have no idea if there is some intended waiting in mongo (legacy) shell, or if it is even a problem in the server's getMore command implementation.

      For reference, mongosh offers two functions: cursor.hasNext() and cursor.tryNext() and from the docs one can infer that cursor.hasNext() is 'blocking', so it might include some waiting (and a timeout?). mongo (legacy) shell does not have cursor.tryNext() counterpart.

            Assignee:
            ian.boros@mongodb.com Ian Boros
            Reporter:
            romans.kasperovics@mongodb.com Romans Kasperovics
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: