Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-1788

Aggregate explain broken on 4.2 server

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.10.0.rc0
    • Affects Version/s: None
    • Component/s: None
    • Fully Compatible

      It appears that 4.2 changed the format in which it reports aggregate explain results.

      4.0:

      ruby-driver-rs:PRIMARY> db.test.explain().aggregate([])
      {
      	"stages" : [
      		{
      			"$cursor" : {
      				"query" : {
      					
      				},
      				"queryPlanner" : {
      					"plannerVersion" : 1,
      					"namespace" : "ruby-driver.test",
      					"indexFilterSet" : false,
      					"parsedQuery" : {
      						
      					},
      					"winningPlan" : {
      						"stage" : "COLLSCAN",
      						"direction" : "forward"
      					},
      					"rejectedPlans" : [ ]
      				}
      			}
      		}
      	],
      	"ok" : 1,
      	"operationTime" : Timestamp(1554485036, 1),
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1554485036, 1),
      		"signature" : {
      			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      			"keyId" : NumberLong(0)
      		}
      	}
      }
      

      4.2:

      ruby-driver-rs:PRIMARY> db.test.explain().aggregate([])
      {
      	"queryPlanner" : {
      		"plannerVersion" : 1,
      		"namespace" : "ruby-driver.test",
      		"indexFilterSet" : false,
      		"parsedQuery" : {
      			
      		},
      		"queryHash" : "8B3D4AB8",
      		"planCacheKey" : "8B3D4AB8",
      		"optimizedPipeline" : true,
      		"winningPlan" : {
      			"stage" : "COLLSCAN",
      			"direction" : "forward"
      		},
      		"rejectedPlans" : [ ]
      	},
      	"serverInfo" : {
      		"host" : "speed",
      		"port" : 27741,
      		"version" : "4.1.9-283-g1b75c7b9b1",
      		"gitVersion" : "1b75c7b9b1295fa8a94552da7f2c63cbc2cc2105"
      	},
      	"ok" : 1,
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1554484992, 1),
      		"signature" : {
      			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      			"keyId" : NumberLong(0)
      		}
      	},
      	"operationTime" : Timestamp(1554484992, 1)
      }
      

      The `queryPlanner` key got moved to top level where previously it was under `stages` key. The driver expects the response to have a `stages` key and fails thusly on 4.2:

       1) ./spec/mongo/collection/view/aggregation_spec.rb[1:4:1]
      
      Mongo::Collection::View::Aggregation#explain executes an explain
      
      NoMethodError: undefined method `[]' for nil:NilClass
      
      /data/mci/a01d1b690953c11a290f354659ef7fdc/src/lib/mongo/operation/aggregate/result.rb:68:in `documents'
      /data/mci/a01d1b690953c11a290f354659ef7fdc/src/lib/mongo/cursor.rb:298:in `process'
      /data/mci/a01d1b690953c11a290f354659ef7fdc/src/lib/mongo/cursor.rb:123:in `each'
      /data/mci/a01d1b690953c11a290f354659ef7fdc/src/lib/mongo/collection/view/iterable.rb:45:in `each'
      /data/mci/a01d1b690953c11a290f354659ef7fdc/src/lib/mongo/collection/view/aggregation.rb:88:in `first'
      /data/mci/a01d1b690953c11a290f354659ef7fdc/src/lib/mongo/collection/view/aggregation.rb:88:in `explain'
      /data/mci/a01d1b690953c11a290f354659ef7fdc/src/spec/mongo/collection/view/aggregation_spec.rb:224:in `block (3 levels) in <top (required)>'
      

            Assignee:
            hana.pearlman@mongodb.com Hana Pearlman
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: