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

[SBE][sharding] invariant failure: _projectVars.size != _projectFields.size during covered_shard_key_indexes.js

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.0.0-rc0
    • Affects Version/s: None
    • Component/s: Querying, Sharding
    • None
    • Fully Compatible

      During covered_shard_key_indexes.js we hit this invariant:

      [js_test:covered_shard_key_indexes] d20020| 2021-04-06T19:23:21.313+00:00 D5 QUERY    20967   [conn30] "Beginning planning","attr":{"options":"INCLUDE_SHARD_FILTER INDEX_INTERSECTION SPLIT_LIMITED_SORT ","query":"ns=foo.barTree: a $eq true\nSort: {}\nProj: { _id: 1.0, a: 
      [js_test:covered_shard_key_indexes] d20020| 2021-04-06T19:23:21.313+00:00 D5 QUERY    20968   [conn30] "Index number and details","attr":{"indexNumber":0,"index":"kp: { _id: 1 } unique name: '(_id_, )' io: { v: 2, key: { _id: 1 }, name: \"_id_\" }"}
      [js_test:covered_shard_key_indexes] d20020| 2021-04-06T19:23:21.313+00:00 D5 QUERY    20968   [conn30] "Index number and details","attr":{"indexNumber":1,"index":"kp: { a: 1.0, _id: 1.0 } name: '(a_1__id_1, )' io: { v: 2, key: { a: 1.0, _id: 1.0 }, name: \"a_1__id_1\" }"}
      [js_test:covered_shard_key_indexes] d20020| 2021-04-06T19:23:21.313+00:00 D5 QUERY    20970   [conn30] "Predicate over field","attr":{"field":"a"}
      [js_test:covered_shard_key_indexes] d20020| 2021-04-06T19:23:21.313+00:00 D2 QUERY    20971   [conn30] "Relevant index","attr":{"indexNumber":0,"index":"kp: { a: 1.0, _id: 1.0 } name: '(a_1__id_1, )' io: { v: 2, key: { a: 1.0, _id: 1.0 }, name: \"a_1__id_1\" }"}
      [js_test:covered_shard_key_indexes] d20020| | 2021-04-06T19:23:21.313+00:00 D5 QUERY    20972   [conn30] "Rated tree","attr":{"tree":"a $eq true  || First: 0 notFirst: full path: a\n"}
      [js_test:covered_shard_key_indexes] d20020| 2021-04-06T19:23:21.313+00:00 D5 QUERY    20944   [conn30] "Tagging memoID","attr":{"id":1}
      [js_test:covered_shard_key_indexes] d20020| 2021-04-06T19:23:21.313+00:00 D5 QUERY    20943   [conn30] "Enumerator: memo just before moving","attr":{"memo":"[Node #1]: AND enumstate counter 0\n\tchoice 0:\n\t\tsubnodes: \n\t\tidx[0]\n\t\t\tpos 0 pred a $eq true\n\n"}
      [js_test:covered_shard_key_indexes] d20020| | 2021-04-06T19:23:21.313+00:00 D5 QUERY    20976   [conn30] "About to build solntree from tagged tree","attr":{"tree":"a $eq true  || Selected Index #0 pos 0 combine 1\n"}
      [js_test:covered_shard_key_indexes] d20020| 2021-04-06T19:23:21.313+00:00 D5 QUERY    20949   [conn30] "PROJECTION: Current plan","attr":{"plan":"SHARDING_FILTER\n---nodeId = 0\n---fetched = 0\n---sortedByDiskLoc = 0\n---providedSorts = {baseSortPattern: { _id: 1 }, ignor
      [js_test:covered_shard_key_indexes] d20020| 2021-04-06T19:23:21.313+00:00 D5 QUERY    20978   [conn30] "Planner: adding solution","attr":{"solution":"PROJ\n---proj = { _id: true, a: true }\n---type = COVERED_ONE_INDEX\n---nodeId = 3\n---fetched = 0\n---sortedByDiskLoc = 0
      [js_test:covered_shard_key_indexes] d20020| 2021-04-06T19:23:21.313+00:00 D5 QUERY    20979   [conn30] "Planner: outputted indexed solutions","attr":{"numSolutions":1}
      [js_test:covered_shard_key_indexes] d20020| 2021-04-06T19:23:21.313+00:00 D5 QUERY    4742905 [conn30] "Number of generated interval(s) for ixscan","attr":{"num":1}
      [js_test:covered_shard_key_indexes] d20020| 2021-04-06T19:23:21.313+00:00 D5 QUERY    4742906 [conn30] "Generated interval [lowKey, highKey]","attr":{"lowKey":{"":{"$minKey":1}},"highKey":{"":{"$maxKey":1}}}
      [js_test:covered_shard_key_indexes] d20020| 2021-04-06T19:23:21.313+00:00 F  -        23079   [conn30] "Invariant failure","attr":{"expr":"_projectVars.size() == _projectFields.size()","file":"src/mongo/db/exec/sbe/stages/makeobj.cpp","line":59}
      [js_test:covered_shard_key_indexes] d20020| 2021-04-06T19:23:21.313+00:00 F  -        23080   [conn30] "\n\n***aborting after invariant() failure\n\n"
      

      The triggering code is the constructor of MakeObjStageBase:

      template <MakeObjOutputType O>
      MakeObjStageBase<O>::MakeObjStageBase(std::unique_ptr<PlanStage> input,
                                            value::SlotId objSlot,
                                            boost::optional<value::SlotId> rootSlot,
                                            boost::optional<FieldBehavior> fieldBehavior,
                                            std::vector<std::string> fields,
                                            std::vector<std::string> projectFields,
                                            value::SlotVector projectVars,
                                            bool forceNewObject,
                                            bool returnOldObject,
                                            PlanNodeId planNodeId)
          : PlanStage(O == MakeObjOutputType::object ? "mkobj"_sd : "mkbson"_sd, planNodeId),
            _objSlot(objSlot),
            _rootSlot(rootSlot),
            _fieldBehavior(fieldBehavior),
            _fields(std::move(fields)),
            _projectFields(std::move(projectFields)),
            _projectVars(std::move(projectVars)),
            _forceNewObject(forceNewObject),
            _returnOldObject(returnOldObject) {
          _children.emplace_back(std::move(input));
          invariant(_projectVars.size() == _projectFields.size());  // <----- fails
      

      https://github.com/mongodb/mongo/blob/master/src/mongo/db/exec/sbe/stages/makeobj.cpp#L59

      As part of fixing this failure it might be helpful to include the sizes of the projectVars and projectFields vectors.

            Assignee:
            ian.boros@mongodb.com Ian Boros
            Reporter:
            kyle.suarez@mongodb.com Kyle Suarez
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: