[SERVER-55889] [SBE][sharding] invariant failure: _projectVars.size != _projectFields.size during covered_shard_key_indexes.js Created: 07/Apr/21  Updated: 29/Oct/23  Resolved: 12/Apr/21

Status: Closed
Project: Core Server
Component/s: Querying, Sharding
Affects Version/s: None
Fix Version/s: 5.0.0-rc0

Type: Task Priority: Major - P3
Reporter: Kyle Suarez Assignee: Ian Boros
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-55010 Enable sharding suite against SBE bui... Closed
Backwards Compatibility: Fully Compatible
Participants:

 Description   

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.



 Comments   
Comment by Githook User [ 12/Apr/21 ]

Author:

{'name': 'Ian Boros', 'email': 'ian.boros@mongodb.com', 'username': 'puppyofkosh'}

Message: SERVER-55889 Fix parent/child mismatch in slot vectors produced for shard filtering stage
Branch: master
https://github.com/mongodb/mongo/commit/611eed2b11ace4a508c1e0f26e770af5a460446c

Generated at Thu Feb 08 05:37:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.