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

aggregation pipeline cursor option crashes when used against a replica set

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.12
    • Affects Version/s: 1.10.2, 1.11.0
    • Component/s: Replica Set
    • None
    • Environment:
      Amazon Linux 2014.09, mongodb 2.6.4, ruby 2.1.2

      I've been unable to use the cursor option with the aggregation pipeline when using a replica set connection. An exception is raised when send_get_more runs because @pool is nil, although I don't understand enough about the aggregation pipeline to know why.

      I've included a sample that reproduces the issue - this is basically lifted from the test_aggregation_cursor test. If I swap the connection for just Mongo::MongoClient then the snippet runs successfully

      require 'mongo'
      client = Mongo::MongoReplicaSetClient.new ['127.0.0.1'], :logger => logger
      db = client.db 'agg_test'
      test = db.collection("test")
      
      size = 10
      test.drop
      size.times {|i| test.insert({ :_id => i }) }
      expected_sum = size.times.reduce(:+)
      cursor = test.aggregate(
        [{ :$project => {:_id => '$_id'}} ],
        :cursor => {:batchSize => 1}
      )
      
      cursor_sum = cursor.reduce(0) do |sum, doc|
        sum += doc['_id']
      end
      

      The backtrace is

      NoMethodError: undefined method `checkout' for nil:NilClass
      	from /usr/local/rvm/gems/ruby-2.1.3/gems/mongo-1.11.1/lib/mongo/cursor.rb:598:in `send_get_more'
      	from /usr/local/rvm/gems/ruby-2.1.3/gems/mongo-1.11.1/lib/mongo/cursor.rb:531:in `refresh'
      	from /usr/local/rvm/gems/ruby-2.1.3/gems/mongo-1.11.1/lib/mongo/cursor.rb:136:in `next'
      	from /usr/local/rvm/gems/ruby-2.1.3/gems/mongo-1.11.1/lib/mongo/cursor.rb:339:in `each'
      {

      }

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            fcheung Frederick Cheung
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: