querySettings with cursor batchSize 0 stops the server

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Gone away
    • Priority: Major - P3
    • None
    • Affects Version/s: 8.2.4, 8.2.6, 8.2.12
    • Component/s: None
    • None
    • Query Execution
    • ALL
    • Hide
      docker run -d --name repro mongo:8.2.12
      
      # wait for startup, then:
      docker exec repro mongosh --quiet test --eval '
        db.runCommand({aggregate: 1, pipeline: [{$querySettings: {}}], cursor: {batchSize: 0}});
      '
      
      docker inspect repro --format '{{.State.Status}} exit={{.State.ExitCode}}'
      

      The last line reports exited exit=139. No collection is needed.

      Show
      docker run -d --name repro mongo:8.2.12 # wait for startup, then: docker exec repro mongosh --quiet test --eval ' db.runCommand({aggregate: 1, pipeline: [{$querySettings: {}}], cursor: {batchSize: 0}}); ' docker inspect repro --format '{{.State.Status}} exit={{.State.ExitCode}}' The last line reports exited exit=139 . No collection is needed.
    • QE 2026-08-17
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Opening a $querySettings cursor with a zero first batch stops the server. A zero
      batch size is the usual way to get a cursor without fetching documents yet, so drivers
      can do this on their own.

      Both parts are needed, neither one alone seems to cause a problem.

      Command Result
      aggregate 1, pipeline $documents, cursor batchSize 0 cursor returned
      aggregate on a collection, pipeline $match, cursor batchSize 0 cursor returned
      aggregate 1, pipeline $querySettings, cursor batchSize 1 ok
      aggregate 1, pipeline $querySettings, empty cursor document ok
      aggregate 1, pipeline $querySettings, cursor batchSize 0 server stops

      It also seems to happen against admin.

      Expected

      An empty first batch and a cursor id, the same as batchSize: 1 already returns.

      Actual

      The server stops and the process exits with 139.

      My runs were all on a standalone instance where setQuerySettings is not available, so $querySettings had nothing to return. Whether that matters I'm not sure.

            Assignee:
            Denis Grebennicov
            Reporter:
            Daniel Frankcom (EXT)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: