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

Investigate failing $unionWith tests when `checkOnPrimaryShardForDb` is removed

    • Sharding EMEA
    • QE 2023-08-07

      The code in attachCursorToPipeline performs routing and when it thinks that the collection is UNSHARDED, it will attempt to take the optimised path, establishing cursors locally, though DBDirectClient, instead of making a remote call.

      In order to do this, it sets the expected state of the collection correctly on the OpCtx, and then makes a call, which eventually will enter in the shard role. Since this call will already ensure that the cursors are established on the right shard, by virtue of entering the shard role and the checks that this involves (namely db primary and shard version), it is unnecessary (and wrong by itself) to call checkOnPrimaryShardForDb, because that check can be invalid as soon as that function returns.

      When this line is removed, however, there are failures in some $unionWith tests, which indicates that there are places where query doesn't correctly perform shard version checking.

      The goal of this ticket is to investigate and fix the respective query bugs as a prerequisite for SERVER-74816.

            Assignee:
            ivan.fefer@mongodb.com Ivan Fefer
            Reporter:
            kaloian.manassiev@mongodb.com Kaloian Manassiev
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: