[SERVER-69595] Explain v2 does not work with Bonsai in 6.2 Created: 12/Sep/22  Updated: 27/Oct/23  Resolved: 12/Sep/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Alexander Ignatyev Assignee: Backlog - Query Optimization
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Optimization
Operating System: ALL
Steps To Reproduce:

1. checkout the latest version of mongo (in my case 3ec1e222a0a6144d94888578e09c256b14bddc00) and enterprise module (f6c3a2c4f30b00917b60964e04fe0d2fca27a88b)
2. build it
3. run using the following command:

./build/install/bin/mongod --setParameter enableTestCommands=true --setParameter featureFlagCommonQueryFramework=true --setParameter internalQueryFrameworkControl=forceBonsai

4. run mongosh
5. execute in mongosh:

db.adminCommand({'configureFailPoint': 'enableExplainInBonsai', 'mode': 'alwaysOn'});

6. run a simple command like and check explain version

db.coll.find({a: 1}).explain()

older version:

Enterprise test> db.version()
6.1.0-alpha-2354-g763f86d
Enterprise test> db.adminCommand({'configureFailPoint': 'enableExplainInBonsai', 'mode': 'alwaysOn'});
{ count: 0, ok: 1 }
Enterprise test> db.adminCommand({'getParameter': 1, 'internalQueryFrameworkControl': 1});
{ internalQueryFrameworkControl: 'forceBonsai', ok: 1 }
Enterprise test> db.adminCommand({'getParameter': 1, 'featureFlagCommonQueryFramework': 1});
{
  featureFlagCommonQueryFramework: { value: true, version: '6.1' },
  ok: 1
}
Enterprise test> db.coll.find({a: 1}).explain()
{
  explainVersion: '2',
  queryPlanner: {
    namespace: 'test.coll',
    indexFilterSet: false,
    optimizedPipeline: true,
    maxIndexedOrSolutionsReached: false,
...

Participants:

 Description   

When I try to run cost calibration on newer versions of mongod explain always return v1, older version of mongod (e.g. 6.1) works just fine.

Enterprise test> db.version()
6.2.0-alpha-244-gd870dda
Enterprise test> db.adminCommand({'configureFailPoint': 'enableExplainInBonsai', 'mode': 'alwaysOn'});
{ count: 0, ok: 1 }
Enterprise test> db.adminCommand({'getParameter': 1, 'featureFlagCommonQueryFramework': 1});
{
  featureFlagCommonQueryFramework: { value: true, version: '6.2' },
  ok: 1
}
Enterprise test> db.adminCommand({'getParameter': 1, 'internalQueryFrameworkControl': 1});
{ internalQueryFrameworkControl: 'forceBonsai', ok: 1 }
Enterprise test> db.coll.drop()
true
Enterprise test> db.coll.find({a: 1}).explain()
{
  explainVersion: '1',
  queryPlanner: {
    namespace: 'test.coll',
    indexFilterSet: false,
    parsedQuery: { a: { '$eq': 1 } },
    maxIndexedOrSolutionsReached: false,
    maxIndexedAndSolutionsReached: false,
    maxScansToExplodeReached: false,
    winningPlan: { stage: 'EOF' },
    rejectedPlans: []
  },
  command: { find: 'coll', filter: { a: 1 }, '$db': 'test' },
  serverInfo: {
    host: 'ip-10-122-6-29',
    port: 27017,
    version: '6.2.0-alpha-244-gd870dda',
    gitVersion: 'd870dda33fb75983f628636ff8f849c7f1c90b09'
  },
  serverParameters: {
    internalQueryFacetBufferSizeBytes: 104857600,
    internalQueryFacetMaxOutputDocSizeBytes: 104857600,
    internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600,
    internalDocumentSourceGroupMaxMemoryBytes: 104857600,
    internalQueryMaxBlockingSortMemoryUsageBytes: 104857600,
    internalQueryProhibitBlockingMergeOnMongoS: 0,
    internalQueryMaxAddToSetBytes: 104857600,
    internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600
  },
  ok: 1
}



 Comments   
Comment by Alexander Ignatyev [ 12/Sep/22 ]

I can confirm that with featureCompatinbilityVersions = 6.2 it works fine. You may close the ticket.

Thhank you for looking into it!

Enterprise test> db.adminCommand({setFeatureCompatibilityVersion: "6.2"})
{ ok: 1 }
Enterprise test> db.adminCommand({getParameter: 1, featureCompatibilityVersion: 1});
{ featureCompatibilityVersion: { version: '6.2' }, ok: 1 }
Enterprise test> db.coll.find({a: 1}).explain()
{
  explainVersion: '2',

Comment by Nicholas Zolnierz [ 12/Sep/22 ]

I was able to reproduce manually with the steps that Alex provided. It appears to be an FCV issue as the server is starting in FCV 6.1 which means that the CQF feature flag will be considered "false" (although it's interesting that running getParameter shows it to be set).

Generated at Thu Feb 08 06:13:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.