From 3e6190b7585f55a136590613b2e4d022db4e2387 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 1 Feb 2024 17:43:26 +0100 Subject: [PATCH] chore(mongodb-explain-compat): add 7.2 mongos unsharded collection explain COMPASS-7603 (#5398) It doesn't look like code changes are necessary for us, so just adding example data as a test case here should be enough for this ticket. --- .../unsharded-aggregate-on-mongos.7.2.in.json | 113 ++++++++++++++++++ ...unsharded-aggregate-on-mongos.7.2.out.json | 113 ++++++++++++++++++ packages/mongodb-explain-compat/test/index.js | 6 + 3 files changed, 232 insertions(+) create mode 100644 packages/mongodb-explain-compat/test/fixtures/unsharded-aggregate-on-mongos.7.2.in.json create mode 100644 packages/mongodb-explain-compat/test/fixtures/unsharded-aggregate-on-mongos.7.2.out.json diff --git a/packages/mongodb-explain-compat/test/fixtures/unsharded-aggregate-on-mongos.7.2.in.json b/packages/mongodb-explain-compat/test/fixtures/unsharded-aggregate-on-mongos.7.2.in.json new file mode 100644 index 00000000000..d195e64dfb3 --- /dev/null +++ b/packages/mongodb-explain-compat/test/fixtures/unsharded-aggregate-on-mongos.7.2.in.json @@ -0,0 +1,113 @@ +{ + "serverInfo": { + "host": "M-C02D23CNMD6R", + "port": 27017, + "version": "7.3.0-alpha1-184-gef22b28", + "gitVersion": "ef22b2853f29e36ff86c78e8f3d5627508252826" + }, + "serverParameters": { + "internalQueryFacetBufferSizeBytes": 104857600, + "internalQueryFacetMaxOutputDocSizeBytes": 104857600, + "internalLookupStageIntermediateDocumentMaxSizeBytes": 104857600, + "internalDocumentSourceGroupMaxMemoryBytes": 104857600, + "internalQueryMaxBlockingSortMemoryUsageBytes": 104857600, + "internalQueryProhibitBlockingMergeOnMongoS": 0, + "internalQueryMaxAddToSetBytes": 104857600, + "internalDocumentSourceSetWindowFieldsMaxMemoryBytes": 104857600, + "internalQueryFrameworkControl": "trySbeRestricted" + }, + "splitPipeline": null, + "shards": { + "replSet-a3becde9-cc49-4b7d-94c8-266bc36068ef": { + "host": "127.0.0.1:64745", + "stages": [ + { + "$cursor": { + "queryPlanner": { + "namespace": "test.coll", + "indexFilterSet": false, + "parsedQuery": {}, + "queryHash": "E0087D7B", + "planCacheKey": "2FE566FB", + "optimizationTimeMillis": 0, + "maxIndexedOrSolutionsReached": false, + "maxIndexedAndSolutionsReached": false, + "maxScansToExplodeReached": false, + "winningPlan": { + "isCached": false, + "stage": "PROJECTION_SIMPLE", + "transformBy": { + "_id": true, + "author": true, + "tags": true + }, + "inputStage": { + "stage": "COLLSCAN", + "direction": "forward" + } + }, + "rejectedPlans": [] + } + } + }, + { + "$unwind": { + "path": "$tags" + } + }, + { + "$group": { + "_id": { + "tags": "$tags" + }, + "authors": { + "$addToSet": "$author" + } + } + } + ] + } + }, + "command": { + "aggregate": "coll", + "pipeline": [ + { + "$project": { + "author": 1, + "tags": 1 + } + }, + { + "$unwind": "$tags" + }, + { + "$group": { + "_id": { + "tags": "$tags" + }, + "authors": { + "$addToSet": "$author" + } + } + } + ], + "cursor": {} + }, + "ok": 1, + "$clusterTime": { + "clusterTime": { + "$timestamp": "7329888704586055681" + }, + "signature": { + "hash": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", + "keyId": { + "low": 0, + "high": 0, + "unsigned": false + } + } + }, + "operationTime": { + "$timestamp": "7329888691701153793" + } +} diff --git a/packages/mongodb-explain-compat/test/fixtures/unsharded-aggregate-on-mongos.7.2.out.json b/packages/mongodb-explain-compat/test/fixtures/unsharded-aggregate-on-mongos.7.2.out.json new file mode 100644 index 00000000000..d195e64dfb3 --- /dev/null +++ b/packages/mongodb-explain-compat/test/fixtures/unsharded-aggregate-on-mongos.7.2.out.json @@ -0,0 +1,113 @@ +{ + "serverInfo": { + "host": "M-C02D23CNMD6R", + "port": 27017, + "version": "7.3.0-alpha1-184-gef22b28", + "gitVersion": "ef22b2853f29e36ff86c78e8f3d5627508252826" + }, + "serverParameters": { + "internalQueryFacetBufferSizeBytes": 104857600, + "internalQueryFacetMaxOutputDocSizeBytes": 104857600, + "internalLookupStageIntermediateDocumentMaxSizeBytes": 104857600, + "internalDocumentSourceGroupMaxMemoryBytes": 104857600, + "internalQueryMaxBlockingSortMemoryUsageBytes": 104857600, + "internalQueryProhibitBlockingMergeOnMongoS": 0, + "internalQueryMaxAddToSetBytes": 104857600, + "internalDocumentSourceSetWindowFieldsMaxMemoryBytes": 104857600, + "internalQueryFrameworkControl": "trySbeRestricted" + }, + "splitPipeline": null, + "shards": { + "replSet-a3becde9-cc49-4b7d-94c8-266bc36068ef": { + "host": "127.0.0.1:64745", + "stages": [ + { + "$cursor": { + "queryPlanner": { + "namespace": "test.coll", + "indexFilterSet": false, + "parsedQuery": {}, + "queryHash": "E0087D7B", + "planCacheKey": "2FE566FB", + "optimizationTimeMillis": 0, + "maxIndexedOrSolutionsReached": false, + "maxIndexedAndSolutionsReached": false, + "maxScansToExplodeReached": false, + "winningPlan": { + "isCached": false, + "stage": "PROJECTION_SIMPLE", + "transformBy": { + "_id": true, + "author": true, + "tags": true + }, + "inputStage": { + "stage": "COLLSCAN", + "direction": "forward" + } + }, + "rejectedPlans": [] + } + } + }, + { + "$unwind": { + "path": "$tags" + } + }, + { + "$group": { + "_id": { + "tags": "$tags" + }, + "authors": { + "$addToSet": "$author" + } + } + } + ] + } + }, + "command": { + "aggregate": "coll", + "pipeline": [ + { + "$project": { + "author": 1, + "tags": 1 + } + }, + { + "$unwind": "$tags" + }, + { + "$group": { + "_id": { + "tags": "$tags" + }, + "authors": { + "$addToSet": "$author" + } + } + } + ], + "cursor": {} + }, + "ok": 1, + "$clusterTime": { + "clusterTime": { + "$timestamp": "7329888704586055681" + }, + "signature": { + "hash": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", + "keyId": { + "low": 0, + "high": 0, + "unsigned": false + } + } + }, + "operationTime": { + "$timestamp": "7329888691701153793" + } +} diff --git a/packages/mongodb-explain-compat/test/index.js b/packages/mongodb-explain-compat/test/index.js index 0ef41dfda95..1ee2329a866 100644 --- a/packages/mongodb-explain-compat/test/index.js +++ b/packages/mongodb-explain-compat/test/index.js @@ -105,6 +105,12 @@ describe('convertExplainCompat', () => { fixture('unsharded-find.sbe.out') ); }); + it('handles 7.2 (SERVER-79724) changes to mongos explain for unsharded collections', () => { + assert.deepStrictEqual( + convertExplainCompat(fixture('unsharded-aggregate-on-mongos.7.2.in')), + fixture('unsharded-aggregate-on-mongos.7.2.out') + ); + }); }); describe('explain mode "queryPlanner"', function () {