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

$setWindowFields getting nondeterministic order of input would output nondeterministic result if ‘sortBy’ a non-existing field

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.0.0-rc1, 5.1.0-rc0
    • Component/s: None
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v5.0
    • Sprint:
      Query Optimization 2021-05-17, Query Optimization 2021-05-31
    • Linked BF Score:
      130

      Description

      If the preceding stages generate output in nondeterministic order and $setWindowFields has a default ‘partitionBy’ and ‘sortBy’ a non-existing field, $setWindowFields could generate inconsistent result every time the same pipeline is executed.

      Due to the same reason, disabling/enabling query optimization could also cause $setWindowFields producing inconsistent result. For example in BF-20745, consider a pipeline [*$bucket + $setWindowFields]* which will be desugared to the following pipeline: [ $group + $sort ({“_id”: 1})  + $sort + $_internalSetWindowFields ]. The two adjacent $sort stages will be optimized to a single $sort by removing the first $sort. However, if the second $sort sorted a non-existing field, $_internalSetWindowFields would still get a non-deterministic order of input because $group does not order its output.

       

      It seems not a legit $setWindowFields bug, but it’s failing in some certain agg-fuzzers, e.g. aggregation_wildcard_fuzzer and aggregation_optimization_fuzzer.

       

        Attachments

          Activity

            People

            Assignee:
            samuel.mercier Sam Mercier
            Reporter:
            ruoxin.xu Ruoxin Xu
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: