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

mergeByPBRT may cause incompatible error

    • ALL
    • Query 2020-01-27, Query 2020-02-10, Query 2020-03-09

      1. MongoDB 4.0.7  add mergeByPBRT option between mongos and mongod
      2. if mongos has upgraded to a new version,the normal aggregation command to mongod below 4.0.7 will cause access error.
      mongos> db.test.aggregate([{"$match":{"c32":17}}, {"$group":{"_id":null, "total":{"$sum":"$float"}}}])
      2019-12-30T19:59:16.398+0800 E QUERY    [js] Error: command failed: {
          "ok" : 0,
          "errmsg" : "unrecognized field 'mergeByPBRT'",
          "code" : 9,
          "codeName" : "FailedToParse",
          "operationTime" : Timestamp(1577707153, 1),
          "$clusterTime" : {
              "clusterTime" : Timestamp(1577707155, 3),
              "signature" : {
                  "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                  "keyId" : NumberLong(0)
              }
          }
      }

       

      Workaround,only add mergeByPBRT option in change stream aggregation command.

      diff --git a/src/mongo/s/commands/cluster_aggregate.cpp b/src/mongo/s/commands/cluster_aggregate.cpp
      index d58ce76220..a2c308a353 100644
      --- a/src/mongo/s/commands/cluster_aggregate.cpp
      +++ b/src/mongo/s/commands/cluster_aggregate.cpp
      @@ -215,7 +215,9 @@ BSONObj createCommandForTargetedShards(
                   targetedCmd[AggregationRequest::kNeedsMergeName] = Value(true);
                   // If this is a change stream, set the 'mergeByPBRT' flag on the command. This notifies
                   // the shards that the mongoS is capable of merging streams based on resume token.
      -            targetedCmd[AggregationRequest::kMergeByPBRTName] = Value(litePipe.hasChangeStream());
      +            if (litePipe.hasChangeStream()) {
      +                targetedCmd[AggregationRequest::kMergeByPBRTName] = Value(litePipe.hasChangeStream());
      +            }
                   targetedCmd[AggregationRequest::kCursorName] =
                       Value(DOC(AggregationRequest::kBatchSizeName << 0));
               }
      

            Assignee:
            bernard.gorman@mongodb.com Bernard Gorman
            Reporter:
            zyd_com@126.com Zhang Youdong
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: