Fix caching behavior for SBE plans chosen by CBR

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization
    • ALL
    • Hide

      This repro requires the changes of SERVER-116987

      db.foo.drop()
      const docs = []
      const kNumDocs = 15000
      for (let i = 0; i < kNumDocs; i++) {
          docs.push({a: i, b: i});
      }
      docs.push({a: 7000 + 1, b: 7000 + 1, c: 1});
      docs.push({a: 8000 + 1, b: 8000 + 1, c: 1});
      db.foo.insertMany(docs);
      db.foo.createIndexes([{a: 1}, {b: 1}]);
      db.adminCommand({setParameter: 1, planRankerMode: "automaticCE"})
      db.adminCommand({setParameter: 1, automaticCEPlanRankingStrategy: "CBRForNoMultiplanningResults"})
      
      // puts plan into cache, with 3 "works" but it should be 4 to represent the 2 keys examined + 2 docs examined
      db.foo.aggregate([{$match: {a: 5, b: 10}}, {$group: {_id: "$a", avg: {$avg: "$x"}}}])
      
      // activates plan
      db.foo.aggregate([{$match: {a: 5, b: 10}}, {$group: {_id: "$a", avg: {$avg: "$x"}}}])
      
      db.foo.aggregate([{$match: {a: 5, b: 10}}, {$group: {_id: "$a", avg: {$avg: "$x"}}}])
      // tassert!
      "errmsg" : "Expected variant to hold numReads",
      "code" : 8908810,
      

       

       

      Show
      This repro requires the changes of SERVER-116987 db.foo.drop() const docs = [] const kNumDocs = 15000 for (let i = 0; i < kNumDocs; i++) {     docs.push({a: i, b: i}); } docs.push({a: 7000 + 1, b: 7000 + 1, c: 1}); docs.push({a: 8000 + 1, b: 8000 + 1, c: 1}); db.foo.insertMany(docs); db.foo.createIndexes([{a: 1}, {b: 1}]); db.adminCommand({setParameter: 1, planRankerMode: "automaticCE" }) db.adminCommand({setParameter: 1, automaticCEPlanRankingStrategy: "CBRForNoMultiplanningResults" }) // puts plan into cache, with 3 "works" but it should be 4 to represent the 2 keys examined + 2 docs examined db.foo.aggregate([{$match: {a: 5, b: 10}}, {$group: {_id: "$a" , avg: {$avg: "$x" }}}]) // activates plan db.foo.aggregate([{$match: {a: 5, b: 10}}, {$group: {_id: "$a" , avg: {$avg: "$x" }}}]) db.foo.aggregate([{$match: {a: 5, b: 10}}, {$group: {_id: "$a" , avg: {$avg: "$x" }}}]) // tassert! "errmsg" : "Expected variant to hold numReads" , "code" : 8908810,    
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      When CBR chooses a plan that gets cached, and that plan happens to run in SBE, we run into a tassert because we are storing the number of works in the plan cache entry rather than the number of reads. Note that the accumulator in the repro is necessary to not run into the tassert from SERVER-117093.

            Assignee:
            Unassigned
            Reporter:
            Militsa Sotirova
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: